Policies client
The SDK provides a Policies client to provide read and update operations on policies.
Policies can only be created and deleted internally within Sitecore Content Hub. Externally, they can only be retrieved or modified.
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 documentation.
Get user policies
To get a user's policy, use getUserPolicyAsync:
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 a 64-bit number as an input.
Get user group policies
To get user group policies, use getUserGroupPolicyAsync:
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 a 64-bit number as an input.
Updating policies
After making changes to policies, the policy can be updated as follows:
await client.policies.updateAsync(policy);