Approvals
Approvals
Approvals lists the users and roles who approve publishing under a publish rule. Assign it to PublishRuleModel.Approvers.
When to Use This Class: Use this class to name the approvers of a publish rule.
Conceptual Role: Acts as the data model that PublishRuleModel serializes under the approvers key.
Returns: Approvals. The approvers of a publish rule.
Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Users | List<string>? | No | null | UIDs of the users who can approve. Serialized as users. |
| Roles | List<string>? | No | null | UIDs of the roles whose members can approve. Serialized as roles. |
Class-Level Notes
What the SDK sends.
- The SDK leaves a null list out of the request body and sends an empty list as [].
Method Index
Approvals has no methods. Assign it to PublishRuleModel.Approvers and pass the model to the Create or Update method of PublishRule.
Class-Level Snippet
This snippet sets one user and one role as approvers and updates an existing publish rule.
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>");
PublishRuleModel model = new PublishRuleModel()
{
WorkflowUid = "<WORKFLOW_UID>",
WorkflowStageUid = "<WORKFLOW_STAGE_UID>",
ContentTypes = new List<string> { "blog_post" },
Locales = new List<string> { "en-us" },
Environment = "<ENVIRONMENT_UID>",
Approvers = new Approvals()
{
Users = new List<string> { "<USER_UID>" },
Roles = new List<string> { "<ROLE_UID>" }
}
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Workflow().PublishRule("<PUBLISH_RULE_UID>").Update(model);
Console.WriteLine(response.OpenJsonObjectResponse()["publishing_rule"]?["approvers"]?.ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}