ReleaseItemModel

View as Markdown

ReleaseItemModel

ReleaseItemModel describes one entry or asset in a release: which item, which version and locale, and whether the release publishes or unpublishes it.

When to Use This Class: Use this class to add items to a release or to remove them from one.

Conceptual Role: Acts as the data model that the ReleaseItem class serializes under the item or items key of a request.

Returns: ReleaseItemModel. One entry or asset of a release.

Properties

NameTypeRequiredDefaultDescription
Uidstring?NonullUID of the entry or asset. Serialized as uid.
VersionintNo0Version of the entry or asset to deploy. Serialized as version.
Localestring?NonullLocale code of the item, for example en-us. Serialized as locale.
ContentTypeUIDstring?NonullContent type UID of the entry, or built_io_upload for an asset. Serialized as content_type_uid.
Actionstring?NonullDeploy action for the item, for example publish or unpublish. Serialized as action.

Class-Level Notes

What the API expects.

  • The Content Management API (CMA) reference asks for the UID, version, content type UID, action, and locale of each item in Add a single item to a Release. The SDK checks none of them, so set every property.
  • The CMA reference identifies an asset with the content type UID built_io_upload.

Version is always in the request.

  • The SDK leaves out the string? properties when they are null.
  • Version is int, not int?, so every request body carries it, 0 unless you set it. Set it to the version of the entry or asset you want the release to deploy.

Method Index

ReleaseItemModel has no methods. Set and read its properties directly, and pass the model to the methods of ReleaseItem.

Class-Level Snippet

The snippet below adds an entry and an asset to a release with one request.

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>");

ReleaseItemModel entry = new ReleaseItemModel
{
    Uid = "<ENTRY_UID>",
    ContentTypeUID = "<CONTENT_TYPE_UID>",
    Version = 2,
    Locale = "en-us",
    Action = "publish"
};

ReleaseItemModel asset = new ReleaseItemModel
{
    Uid = "<ASSET_UID>",
    ContentTypeUID = "built_io_upload",
    Version = 1,
    Locale = "en-us",
    Action = "publish"
};

try
{
    client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().CreateMultiple(new List<ReleaseItemModel> { entry, asset });
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request, for example a version the entry does not have
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}