リテンションポリシーを作成

post
https://api.box.com/2.0
/retention_policies

リテンションポリシーを作成します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

boolean本文内省略可能
true

ポリシーの有効期限が近付いたときにファイルの所有者と共同所有者に通知するかどうか。

次の値のいずれか1つ: true,false

boolean本文内省略可能
true

ファイルの所有者がリテンションを延長できるかどうか。

次の値のいずれか1つ: true,false

リテンションポリシーの期間が終了に近づいたときに通知されるユーザーのリスト。

string本文内省略可能
"Policy to retain all reports for at least one month"

リテンションポリシーのテキストによる追加の説明。

string本文内必須
"permanently_delete"

リテンションポリシーの廃棄アクション。permanently_deleteに設定すると、ポリシーによって保持されているコンテンツが完全に削除されます。remove_retentionに設定すると、コンテンツへのリテンションポリシーの適用が解除され、リテンションポリシーの有効期限が切れた後は、ユーザーがコンテンツを削除できるようになります。

次の値のいずれか1つ: permanently_delete,remove_retention

string本文内必須
"Some Policy Name"

リテンションポリシーの名前

string本文内必須
"finite"

リテンションポリシーのタイプ。リテンションポリシーのタイプは、finite (コンテンツを保持する期間が事前にわかっている場合)、またはindefinite (コンテンツを保持する期間が不明な場合) のいずれかになります。

次の値のいずれか1つ: finite,indefinite

string (int32) / number (int32) 本文内
"365"

リテンションポリシーの期間。この値はリテンションポリシーがコンテンツに割り当てられた後、有効である日数を示します。ポリシーのpolicy_typeindefiniteである場合は、retention_lengthindefiniteになります。

string本文内省略可能
"modifiable"

以下のリテンションの種類を指定します。

  • modifiable: リテンションポリシーを変更できます。たとえば、フォルダの追加と削除、ポリシー期間の短縮と延長、または割り当ての削除を行うことができます。リテンションポリシーが規制目的に関連していない場合はこの種類を使用してください。

  • non_modifiable: フォルダの追加、期間の延長、ポリシーの撤回、廃棄アクションまたは通知設定の変更という限られた方法でしかリテンションポリシーを変更できません。割り当ての削除やポリシー期間の短縮など、その他の操作は実行できません。規制に関するリテンションポリシーを確実に遵守する場合はこの種類を使用してください。

次の値のいずれか1つ: modifiable,non_modifiable

レスポンス

新しいリテンションポリシーオブジェクトを返します。

infiniteリテンションポリシーにretention_lengthが指定された場合、誤ったdisposition_actionが設定された場合、または説明の文字数が上限の500文字を超える場合は、bad_requestエラーを返します。

指定した名前を持つリテンションポリシーがすでに存在する場合は、エラーを返します

予期しないクライアントエラー。

post
リテンションポリシーを作成
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X POST "https://api.box.com/2.0/retention_policies" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "policy_name": "Some Policy Name",
       "policy_type": "finite",
       "retention_length": 365,
       "disposition_action": "permanently_delete"
     }'
.NET
var policyParams = new BoxRetentionPolicyRequest()
{
    PolicyName = "Important Documents!",
    PolicyType = "finite",
    RetentionLength = 365,
    DispositionAction = "remove_retention"
};
BoxRetentionPolicy policy = await client.RetentionPoliciesManager
    .CreateRetentionPolicyAsync(policyParams);
Java
BoxRetentionPolicy.createIndefinitePolicy(api, name);
Python
policy_name = 'Test Indefinite Policy Name'
disposition_action = 'remove_retention'
indefinite_retention_policy = client.create_retention_policy(policy_name, disposition_action, float('inf'))
print(f'Indefinite Retention Policy ID is {indefinite_retention_policy.id} and the policy name is {indefinite_retention_policy.policy_name}')
Node
client.retentionPolicies.create(
	'Tax Documents',
	client.retentionPolicies.policyTypes.INDEFINITE,
	client.retentionPolicies.dispositionActions.REMOVE_RETENTION)
).then(policy => {
	/* policy -> {
		type: 'retention_policy',
		id: '123456789',
		policy_name: 'Tax Documents',
		policy_type: 'indefinite',
		retention_length: 'indefinite',
		retention_type: 'modifiable',
		description: 'Policy to retain all reports',
		disposition_action: 'remove_retention',
		can_owner_extend_retention: false,
		status: 'active',
		are_owners_notified: true,
		custom_notification_recipients: []
		assignment_counts: { enterprise: 0, folder: 1, metadata_template: 0 },
		created_by:
		{ type: 'user',
			id: '11111',
			name: 'Example User',
			login: 'user@example.com' },
		created_at: '2015-05-01T11:12:54-07:00',
		modified_at: '2015-06-08T11:11:50-07:00' }
	*/
});
iOS
client.retentionPolicy.create(
    name: "Test Indefinite Policy Name",
    type: .indefinite,
    dispositionAction: .removeRetention
) { result in
    guard case let .success(retentionPolicy) = result else {
        print("Error creating retention policy")
        return
    }
    
    print("Retention policy: \(retentionPolicy.id) was created")
}

レスポンスの例

{
  "id": "12345",
  "type": "retention_policy",
  "are_owners_notified": false,
  "assignment_counts": {
    "enterprise": 1,
    "folder": 1,
    "metadata_template": 1
  },
  "can_owner_extend_retention": false,
  "created_at": "2012-12-12T10:53:43-08:00",
  "created_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "custom_notification_recipients": [
    {
      "id": "11446498",
      "type": "user",
      "name": "Aaron Levie",
      "login": "ceo@example.com"
    }
  ],
  "description": "Policy to retain all reports for at least one month",
  "disposition_action": "permanently_delete",
  "modified_at": "2012-12-12T10:53:43-08:00",
  "policy_name": "Some Policy Name",
  "policy_type": "finite",
  "retention_length": "365",
  "retention_type": "non_modifiable",
  "status": "active"
}