Box Developerドキュメント
最新バージョン

ストレージポリシーを割り当て

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

会社またはユーザーに対するストレージポリシー割り当てを作成します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

object本文内

ストレージポリシーを割り当てるユーザーまたは会社。

string本文内必須
"9987987"

ユーザーまたは会社のID

string本文内必須
"user"

ポリシーを割り当てるタイプ。

次の値のいずれか1つ: user,enterprise

object本文内

ユーザーまたは会社に割り当てるストレージポリシー

string本文内必須
"1434325"

割り当てるストレージポリシーのID。

string本文内必須
"storage_policy"

割り当てるタイプ。

次の値に固定: storage_policy

レスポンス

作成された新しいストレージポリシー割り当てを返します。

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

post
ストレージポリシーを割り当て
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X POST "https://api.box.com/2.0/storage_policy_assignments" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "storage_policy": {
         "type": "storage_policy",
         "id": "1434325"
       },
       "assigned_to": {
         "type": "user",
         "id": "9987987"
       }
     }'
TypeScript Gen
await client.storagePolicyAssignments.createStoragePolicyAssignment({
  storagePolicy: new CreateStoragePolicyAssignmentRequestBodyStoragePolicyField(
    { id: policyId },
  ),
  assignedTo: {
    id: userId,
    type: 'user' as CreateStoragePolicyAssignmentRequestBodyAssignedToTypeField,
  } satisfies CreateStoragePolicyAssignmentRequestBodyAssignedToField,
} satisfies CreateStoragePolicyAssignmentRequestBody);
Python Gen
client.storage_policy_assignments.create_storage_policy_assignment(
    CreateStoragePolicyAssignmentStoragePolicy(id=policy_id),
    CreateStoragePolicyAssignmentAssignedTo(
        id=user_id, type=CreateStoragePolicyAssignmentAssignedToTypeField.USER
    ),
)
.NET Gen
await client.StoragePolicyAssignments.CreateStoragePolicyAssignmentAsync(requestBody: new CreateStoragePolicyAssignmentRequestBody(storagePolicy: new CreateStoragePolicyAssignmentRequestBodyStoragePolicyField(id: policyId), assignedTo: new CreateStoragePolicyAssignmentRequestBodyAssignedToField(id: userId, type: CreateStoragePolicyAssignmentRequestBodyAssignedToTypeField.User)));
Java
BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.assign(api, "1234", "5678");
Python
user = client.user(user_id='12345')
assignment = client.storage_policy(policy_id='56781').assign(user)
print(f'Assignment ID is {assignment.id} and the assignee id is {assignment.assigned_to.id}')
.NET
BoxStoragePolicyAssignment assignment = client.StoragePoliciesManager
    .CreateAssignmentAsync(userId: "22222", policyId: "6");
Node
client.storagePolicies.createAssignment('7', '22222')
    .then(assignment => {
        /* assignment -> {
            type: 'storage_policy_assignment',
            id: 'dXNlcl8yMjIyMg==',
            storage_policy: 'storage_policy', id: '7' },
            assigned_to: { type: 'user', id: '22222' } }
        */
    });
iOS
client.storagePolicy.assign(storagePolicyId: "1234", assignedToType: "user", assignedToId: "123") { (result: Result<StoragePolicyAssignment, BoxSDKError>) in
    guard case let .success(assignment) = result else {
        print("Error assigning a storage policy")
        return
    }
    print("Created storage policy assignment ID is \(assignment.id). The ID of the user it is assigned to \(assignment.assignedTo?.id)")
}

レスポンスの例

{
  "id": "ZW50ZXJwcmlzZV8xMjM0NTY3ODkw",
  "type": "storage_policy_assignment",
  "assigned_to": {
    "id": "11446498",
    "type": "file"
  },
  "storage_policy": {
    "id": "11446498",
    "type": "storage_policy"
  }
}