DeliveryTokenScope
DeliveryTokenScope
DeliveryTokenScope holds one scope entry of a delivery token: the module it covers, the environments or branches in it, and the permissions. It extends TokenScope with an Environments list.
When to Use This Class: Use this class to set which environments and branches a delivery token can read.
Conceptual Role: Acts as the item type of DeliveryTokenModel.Scope. The SDK serializes the list under the scope key.
Returns: DeliveryTokenScope. One scope entry of a delivery token.
Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Module | string | No | null | Module the entry covers, for example environment or branch. Serialized as module. Inherited from TokenScope. |
| Environments | List<string> | No | null | Environments the token can read, for the environment module. Serialized as environments. |
| Branches | List<string> | No | null | UIDs of the branches the token can read, for the branch module. Serialized as branches. Inherited from TokenScope. |
| ACL | Dictionary<string, string> | No | null | Permissions, for example read set to "true". Serialized as acl. Inherited from TokenScope. |
Class-Level Notes
Nullability.
- The SDK declares the string and List properties without ? and gives them no initial value, so each one holds null until you set it. The SDK leaves null properties out of the request body.
- ACL takes string values, so the SDK sends "true" as a JSON string, not as a boolean.
Additional Resource Refer to Create delivery token for the scope schema.
Method Index
DeliveryTokenScope has no methods. Add it to DeliveryTokenModel.Scope and pass the model to the Create or Update method of DeliveryToken.
Class-Level Snippet
This snippet builds an environment scope and a branch scope, and updates an existing delivery token with them.
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models.Token;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
DeliveryTokenScope environmentScope = new DeliveryTokenScope()
{
Module = "environment",
Environments = new List<string> { "<ENVIRONMENT_UID>" },
ACL = new Dictionary<string, string> { ["read"] = "true" }
};
DeliveryTokenScope branchScope = new DeliveryTokenScope()
{
Module = "branch",
Branches = new List<string> { "main", "development" },
ACL = new Dictionary<string, string> { ["read"] = "true" }
};
DeliveryTokenModel model = new DeliveryTokenModel()
{
Name = "Production Website",
Scope = new List<DeliveryTokenScope> { environmentScope, branchScope }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").DeliveryToken("<DELIVERY_TOKEN_UID>").Update(model);
Console.WriteLine(response.OpenJsonObjectResponse()["token"]?.ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}