DeployModel

View as Markdown

DeployModel

DeployModel holds the target of a release deployment: the environments and locales, the action, and an optional time to run it.

When to Use This Class: Use this class to deploy a release now or at a scheduled time.

Conceptual Role: Acts as the data model that the Deploy method serializes under the release key of the request.

Returns: DeployModel. The target of a release deployment.

Properties

NameTypeRequiredDefaultDescription
EnvironmentsList<string>?NonullNames of the environments to deploy to. Serialized as environments.
LocalesList<string>?NonullLocale codes to deploy, for example en-us. Serialized as locales.
ScheduledAtstring?NonullTime to run the deployment, as an ISO 8601 string. Serialized as scheduledAt.
Actionstring?NonullDeploy action, for example publish or unpublish. Serialized as action.

Class-Level Notes

What the request holds.

  • The SDK leaves out every property that is null. Leave ScheduledAt unset to deploy without a schedule.
  • The SDK serializes ScheduledAt as scheduledAt, in camel case, unlike the snake case keys of most request bodies in this SDK.
  • The Content Management API (CMA) reference describes the body of Deploy a Release as the scheduled time, the action, and the environments of the deployment. The SDK checks none of the properties.

Method Index

DeployModel has no methods. Set its properties directly, and pass the model to the Deploy or DeployAsync method.

Class-Level Snippet

The snippet below schedules a release to publish to two locales of one environment.

using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

DeployModel model = new DeployModel
{
    Environments = new List<string> { "<ENVIRONMENT_NAME>" },
    Locales = new List<string> { "en-us", "fr-fr" },
    Action = "publish",
    ScheduledAt = "2027-03-01T09:00:00.000Z"
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Deploy(model);
    Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request, for example an unknown environment
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}