リテンションポリシーを項目に割り当てます。
ポリシーを割り当てる項目
6564564
ポリシーを割り当てる項目のID。
type
がenterprise
に設定されている場合は、null
に設定するか省略します。
folder
ポリシーを割り当てる項目のタイプ。
次の値のいずれか1つ: enterprise
,folder
,metadata_template
173463
割り当てるリテンションポリシーのID
新しいリテンションポリシー割り当てオブジェクトを返します。
会社にリテンションポリシーを割り当てている最中にid
が指定された場合は、エラーを返します。
指定したpolicy_id
を持つリテンションポリシーが存在しない場合は、エラーを返します。
期間が同じであるか、それよりも長いリテンションポリシーがこの項目にすでに割り当てられている場合は、エラーを返します。
予期しないクライアントエラー。
curl -X POST https://api.box.com/2.0/retention_policy_assignments \
-H 'Authorization: Bearer <ACCESS_TOKEN>" '
-H 'Content-Type: application/json" '
-d '{
"policy_id": "173463",
"assign_to": {
"type": "folder",
"id": "6564564"
}
}'
var assignmentParams = new BoxRetentionPolicyAssignmentRequest()
{
PolicyId = "11111",
AssignTo = new BoxRequestEntity()
{
Type = BoxType.folder,
Id = "22222"
}
};
BoxRetentionPolicyAssignment assignment = await client.RetentionPoliciesManager
.CreateRetentionPolicyAssignmentAsync(assignmentParams);
// Assign the policy to the entire enterprise
BoxRetentionPolicy policy = new BoxRetentionPolicy(api, policyID);
BoxRetentionPolicyAssignment.Info enterpriseAssignmentInfo = policy.assignToEnterprise();
// Assign the policy to a single folder
BoxFolder folder = new BoxFolder(api, folderID);
BoxRetentionPolicyAssignment.Info folderAssignmentInfo = policy.assignTo(folder);
// Assign the policy to all items with metadata template "f0dce190-8106-43ca-9d67-7dce9b10a55e"
BoxRetentionPolicyAssignment.Info metadataAssignmentInfo = policy.assignToMetadataTemplate("f0dce190-8106-43ca-9d67-7dce9b10a55e");
folder = client.folder(folder_id='1111')
assignment = client.retention_policy(policy_id='12345').assign(folder)
print('Assignment ID is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name))
client.retentionPolicies.assign('11111', 'folder', '22222')
.then(assignment => {
/* assignment -> {
type: 'retention_policy_assignment',
id: '12345',
retention_policy:
{ type: 'retention_policy',
id: '11111',
policy_name: 'Tax Documents' },
assigned_to: { type: 'folder', id: '22222' },
assigned_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' },
assigned_at: '2015-07-20T14:28:09-07:00' }
*/
});