Policies client

Version: 3.3

The SDK provides a Policies client to provide read and update operations on policies.

Policies are created and deleted only within Sitecore Content Hub (internally). Externally, they can only be retrieved or modified.

Note

The client variable in the following code examples refers to the ContentHubClient instance. When using the JavaScript SDK, the variable name can be chosen freely, but is also called client at instantiation in the docs.

Get user policies

To get a user's policy, use getUserPolicyAsync:

RequestResponse
import { IUserPolicy } from "@sitecore/sc-contenthub-webclient-sdk/dist/contracts/policies/user-policy";

var policy: IUserPolicy = await client.policies.getUserPolicyAsync(userId);

The userId argument takes 64-bit number as an input.

Get user group policies

Similar to getting a user's policy, use getUserGroupPolicyAsync:

RequestResponse
import { IUserGroupPolicy } from "@sitecore/sc-contenthub-webclient-sdk/dist/contracts/policies/user-group-policy";

var policy: IUserGroupPolicy = await client.policies.getUserGroupPolicyAsync(userGroupId);

The userGroupId argument takes 64-bit number as an input.

Updating policies

After making changes to policies, the policy can be updated as follows:

RequestResponse
await client.policies.updateAsync(policy);

Do you have some feedback for us?

If you have suggestions for improving this article,