ReleaseModel
ReleaseModel
ReleaseModel holds the details of a release. To create a release with the Create method, set Name and optionally Description.
When to Use This Class: Use this class to build the request body for a new or updated release. You can also use it to read a fetched release as a typed object.
Conceptual Role: Acts as the data model that the Release class serializes under the release key of a request.
Returns: ReleaseModel. The details of a release.
Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Name | string? | No | null | Name of the release. The API requires it to create a release. Serialized as name. |
| Description | string? | No | null | Description of the release. Serialized as description. |
| Locked | bool | No | false | Locks the release against changes when true. Serialized as locked. |
| Archived | bool | No | false | Marks the release as archived when true. Serialized as archived. |
Class-Level Notes
The two flags are always in the request.
- The SDK leaves out Name and Description when they are null.
- Locked and Archived are bool, not bool?, so every request body carries them, false unless you set them.
- The Content Management API (CMA) reference documents Lock a Release as an update whose body sets locked. An Update with Locked left at false sends the body that removes a lock. Set Locked = true on every update of a release that should stay locked.
Fields the model does not hold.
- A fetched release carries more fields than these four, for example its uid and timestamps. ReleaseModel has no property for them, so deserializing a release into it drops those fields. Read them from OpenJsonObjectResponse() instead.
Method Index
ReleaseModel has no methods. Set and read its properties directly, and pass the model to the Create or Update method.
Class-Level Snippet
The snippet below creates a release, then locks it with an update that keeps its name and description.
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
Stack stack = client.Stack("<API_KEY>");
try
{
ReleaseModel model = new ReleaseModel { Name = "Spring Launch", Description = "Spring product pages" };
ContentstackResponse response = stack.Release().Create(model);
string releaseUid = response.OpenJsonObjectResponse()["release"]?["uid"]?.ToString() ?? "";
model.Locked = true;
stack.Release(releaseUid).Update(model);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request, for example a missing name
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}