From 3b590b98fbb928de4ef5cc0f9198ff522a077b6b Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 30 Oct 2026 04:04:44 -0700 Subject: [PATCH 1/2] test(SDK-6911): Write documentSplitTest (box/box-codegen#999) --- .codegen.json | 2 +- docs/document_split.md | 27 ++++++++++++-- test/document_split.py | 80 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 test/document_split.py diff --git a/.codegen.json b/.codegen.json index b65b7c31..dacecac4 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "976bbb9", "specHash": "a0e8038", "version": "10.18.0" } +{ "engineHash": "88c0ae7", "specHash": "a0e8038", "version": "10.18.0" } diff --git a/docs/document_split.md b/docs/document_split.md index b3cbaf4a..03625e09 100644 --- a/docs/document_split.md +++ b/docs/document_split.md @@ -25,7 +25,20 @@ This operation is performed by calling function `create_document_split_v2026_r0` See the endpoint docs at [API Reference](https://developer.box.com/reference/v2026.0/post-document-splits/). -_Currently we don't have an example for calling `create_document_split_v2026_r0` in integration tests_ + + +```python +client.document_split.create_document_split_v2026_r0( + file.id, + folder.id, + CreateDocumentSplitV2026R0InputSource.API, + DocumentSplitCreateRequestManualV2026R0( + split_type=DocumentSplitCreateRequestManualV2026R0SplitTypeField.MANUAL, + split_definition=[DocumentSplitPageRangeV2026R0(start=1, end=1)], + ), + external_id=external_id, +) +``` ### Arguments @@ -61,7 +74,11 @@ This operation is performed by calling function `get_document_splits_v2026_r0`. See the endpoint docs at [API Reference](https://developer.box.com/reference/v2026.0/get-document-splits/). -_Currently we don't have an example for calling `get_document_splits_v2026_r0` in integration tests_ + + +```python +client.document_split.get_document_splits_v2026_r0(limit=10) +``` ### Arguments @@ -91,7 +108,11 @@ This operation is performed by calling function `get_document_split_by_id_v2026_ See the endpoint docs at [API Reference](https://developer.box.com/reference/v2026.0/get-document-splits-id/). -_Currently we don't have an example for calling `get_document_split_by_id_v2026_r0` in integration tests_ + + +```python +client.document_split.get_document_split_by_id_v2026_r0(created_document_split.id) +``` ### Arguments diff --git a/test/document_split.py b/test/document_split.py new file mode 100644 index 00000000..7dfef940 --- /dev/null +++ b/test/document_split.py @@ -0,0 +1,80 @@ +from box_sdk_gen.internal.utils import to_string + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas.file_full import FileFull + +from box_sdk_gen.schemas.folder_full import FolderFull + +from box_sdk_gen.schemas.v2026_r0.document_split_create_response_v2026_r0 import ( + DocumentSplitCreateResponseV2026R0, +) + +from box_sdk_gen.managers.document_split import CreateDocumentSplitV2026R0InputSource + +from box_sdk_gen.schemas.v2026_r0.document_split_create_request_manual_v2026_r0 import ( + DocumentSplitCreateRequestManualV2026R0SplitTypeField, +) + +from box_sdk_gen.schemas.v2026_r0.document_split_page_range_v2026_r0 import ( + DocumentSplitPageRangeV2026R0, +) + +from box_sdk_gen.schemas.v2026_r0.document_split_v2026_r0 import DocumentSplitV2026R0 + +from box_sdk_gen.schemas.v2026_r0.document_splits_v2026_r0 import DocumentSplitsV2026R0 + +from box_sdk_gen.internal.utils import get_uuid + +from test.commons import get_default_client + +from test.commons import upload_new_file + +from test.commons import create_new_folder + +from box_sdk_gen.schemas.v2026_r0.document_split_create_request_manual_v2026_r0 import ( + DocumentSplitCreateRequestManualV2026R0, +) + +client: BoxClient = get_default_client() + + +def testCreateDocumentSplitV2026R0(): + file: FileFull = upload_new_file() + folder: FolderFull = create_new_folder() + external_id: str = get_uuid() + created_document_split: DocumentSplitCreateResponseV2026R0 = ( + client.document_split.create_document_split_v2026_r0( + file.id, + folder.id, + CreateDocumentSplitV2026R0InputSource.API, + DocumentSplitCreateRequestManualV2026R0( + split_type=DocumentSplitCreateRequestManualV2026R0SplitTypeField.MANUAL, + split_definition=[DocumentSplitPageRangeV2026R0(start=1, end=1)], + ), + external_id=external_id, + ) + ) + assert not created_document_split.id == '' + assert to_string(created_document_split.type) == 'document_split' + document_split: DocumentSplitV2026R0 = ( + client.document_split.get_document_split_by_id_v2026_r0( + created_document_split.id + ) + ) + assert document_split.id == created_document_split.id + assert to_string(document_split.type) == 'document_split' + assert document_split.source_file.id == file.id + assert document_split.destination_folder.id == folder.id + assert to_string(document_split.input_source) == 'api' + assert not to_string(document_split.status) == '' + assert document_split.external_id == external_id + client.folders.delete_folder_by_id(folder.id, recursive=True) + client.files.delete_file_by_id(file.id) + + +def testGetDocumentSplitsV2026R0(): + document_splits: DocumentSplitsV2026R0 = ( + client.document_split.get_document_splits_v2026_r0(limit=10) + ) + assert len(document_splits.entries) >= 0 From 741285e17f2983a8c080fb1ad35c59fc1b0c4bef Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 4 Nov 2026 08:34:16 -0800 Subject: [PATCH 2/2] feat: Add metadata assignment target to the legal holds API (box/box-openapi#625) --- .codegen.json | 2 +- .../managers/legal_hold_policy_assignments.py | 18 ++++++++++++++++-- box_sdk_gen/schemas/__init__.py | 2 ++ box_sdk_gen/schemas/legal_hold_policy.py | 4 ++++ .../schemas/legal_hold_policy_assigned_item.py | 2 ++ .../schemas/legal_hold_policy_assignment.py | 10 ++++++++++ ...egal_hold_policy_assignment_filter_field.py | 16 ++++++++++++++++ docs/legal_hold_policy_assignments.md | 4 +++- 8 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 box_sdk_gen/schemas/legal_hold_policy_assignment_filter_field.py diff --git a/.codegen.json b/.codegen.json index dacecac4..6e8a50c6 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "88c0ae7", "specHash": "a0e8038", "version": "10.18.0" } +{ "engineHash": "88c0ae7", "specHash": "74452eb", "version": "10.18.0" } diff --git a/box_sdk_gen/managers/legal_hold_policy_assignments.py b/box_sdk_gen/managers/legal_hold_policy_assignments.py index c6ab1145..dc6c0cb6 100644 --- a/box_sdk_gen/managers/legal_hold_policy_assignments.py +++ b/box_sdk_gen/managers/legal_hold_policy_assignments.py @@ -22,6 +22,10 @@ from box_sdk_gen.schemas.legal_hold_policy_assignment import LegalHoldPolicyAssignment +from box_sdk_gen.schemas.legal_hold_policy_assignment_filter_field import ( + LegalHoldPolicyAssignmentFilterField, +) + from box_sdk_gen.schemas.files_on_hold import FilesOnHold from box_sdk_gen.box.errors import BoxSDKError @@ -52,6 +56,7 @@ class GetLegalHoldPolicyAssignmentsAssignToType(str, Enum): USER = 'user' OWNERSHIP = 'ownership' INTERACTIONS = 'interactions' + METADATA_TEMPLATE = 'metadata_template' class CreateLegalHoldPolicyAssignmentAssignToTypeField(str, Enum): @@ -61,6 +66,7 @@ class CreateLegalHoldPolicyAssignmentAssignToTypeField(str, Enum): USER = 'user' OWNERSHIP = 'ownership' INTERACTIONS = 'interactions' + METADATA_TEMPLATE = 'metadata_template' class CreateLegalHoldPolicyAssignmentAssignTo(BaseObject): @@ -71,6 +77,7 @@ class CreateLegalHoldPolicyAssignmentAssignTo(BaseObject): 'user', 'ownership', 'interactions', + 'metadata_template', } def __init__( @@ -176,20 +183,27 @@ def create_legal_hold_policy_assignment( policy_id: str, assign_to: CreateLegalHoldPolicyAssignmentAssignTo, *, + filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> LegalHoldPolicyAssignment: """ - Assign a legal hold to an item type of: file, file version, folder, user, ownership, or interactions. + Assign a legal hold to an item type of: file, file version, folder, user, ownership, interactions, or metadata template. :param policy_id: The ID of the policy to assign. :type policy_id: str :param assign_to: The item to assign the policy to. :type assign_to: CreateLegalHoldPolicyAssignmentAssignTo + :param filter_fields: List of metadata template field filters. Only required when `assign_to.type` is `metadata_template`., defaults to None + :type filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ if extra_headers is None: extra_headers = {} - request_body: Dict = {'policy_id': policy_id, 'assign_to': assign_to} + request_body: Dict = { + 'policy_id': policy_id, + 'assign_to': assign_to, + 'filter_fields': filter_fields, + } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = self.network_session.network_client.fetch( FetchOptions( diff --git a/box_sdk_gen/schemas/__init__.py b/box_sdk_gen/schemas/__init__.py index 3763f1d5..2b6681b4 100644 --- a/box_sdk_gen/schemas/__init__.py +++ b/box_sdk_gen/schemas/__init__.py @@ -204,6 +204,8 @@ from box_sdk_gen.schemas.legal_hold_policy_assignment_base import * +from box_sdk_gen.schemas.legal_hold_policy_assignment_filter_field import * + from box_sdk_gen.schemas.metadata_base import * from box_sdk_gen.schemas.metadata import * diff --git a/box_sdk_gen/schemas/legal_hold_policy.py b/box_sdk_gen/schemas/legal_hold_policy.py index 84763fb3..ca51bbe1 100644 --- a/box_sdk_gen/schemas/legal_hold_policy.py +++ b/box_sdk_gen/schemas/legal_hold_policy.py @@ -32,6 +32,7 @@ def __init__( file_version: Optional[int] = None, ownership: Optional[int] = None, interactions: Optional[int] = None, + metadata_template: Optional[int] = None, **kwargs ): """ @@ -47,6 +48,8 @@ def __init__( :type ownership: Optional[int], optional :param interactions: The number of users this policy is applied to with the `interactions` type assignment., defaults to None :type interactions: Optional[int], optional + :param metadata_template: The number of metadata templates this policy is applied to., defaults to None + :type metadata_template: Optional[int], optional """ super().__init__(**kwargs) self.user = user @@ -55,6 +58,7 @@ def __init__( self.file_version = file_version self.ownership = ownership self.interactions = interactions + self.metadata_template = metadata_template class LegalHoldPolicy(LegalHoldPolicyMini): diff --git a/box_sdk_gen/schemas/legal_hold_policy_assigned_item.py b/box_sdk_gen/schemas/legal_hold_policy_assigned_item.py index 77479f9a..f76d1bb1 100644 --- a/box_sdk_gen/schemas/legal_hold_policy_assigned_item.py +++ b/box_sdk_gen/schemas/legal_hold_policy_assigned_item.py @@ -12,6 +12,7 @@ class LegalHoldPolicyAssignedItemTypeField(str, Enum): USER = 'user' OWNERSHIP = 'ownership' INTERACTIONS = 'interactions' + METADATA_TEMPLATE = 'metadata_template' class LegalHoldPolicyAssignedItem(BaseObject): @@ -22,6 +23,7 @@ class LegalHoldPolicyAssignedItem(BaseObject): 'user', 'ownership', 'interactions', + 'metadata_template', } def __init__(self, type: LegalHoldPolicyAssignedItemTypeField, id: str, **kwargs): diff --git a/box_sdk_gen/schemas/legal_hold_policy_assignment.py b/box_sdk_gen/schemas/legal_hold_policy_assignment.py index b8221d9c..f944afe5 100644 --- a/box_sdk_gen/schemas/legal_hold_policy_assignment.py +++ b/box_sdk_gen/schemas/legal_hold_policy_assignment.py @@ -1,5 +1,7 @@ from typing import Optional +from typing import List + from box_sdk_gen.schemas.legal_hold_policy_assignment_base import ( LegalHoldPolicyAssignmentBaseTypeField, ) @@ -16,6 +18,10 @@ from box_sdk_gen.schemas.user_mini import UserMini +from box_sdk_gen.schemas.legal_hold_policy_assignment_filter_field import ( + LegalHoldPolicyAssignmentFilterField, +) + from box_sdk_gen.box.errors import BoxSDKError from box_sdk_gen.internal.utils import DateTime @@ -32,6 +38,7 @@ def __init__( assigned_by: Optional[UserMini] = None, assigned_at: Optional[DateTime] = None, deleted_at: Optional[DateTime] = None, + filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]] = None, id: Optional[str] = None, type: Optional[LegalHoldPolicyAssignmentBaseTypeField] = None, **kwargs @@ -46,6 +53,8 @@ def __init__( assignment is fully deleted). If null, Assignment was not deleted., defaults to None :type deleted_at: Optional[DateTime], optional + :param filter_fields: List of metadata template field filters. Only present when `assigned_to.type` is `metadata_template`., defaults to None + :type filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]], optional :param id: The unique identifier for this legal hold assignment., defaults to None :type id: Optional[str], optional :param type: The value will always be `legal_hold_policy_assignment`., defaults to None @@ -57,3 +66,4 @@ def __init__( self.assigned_by = assigned_by self.assigned_at = assigned_at self.deleted_at = deleted_at + self.filter_fields = filter_fields diff --git a/box_sdk_gen/schemas/legal_hold_policy_assignment_filter_field.py b/box_sdk_gen/schemas/legal_hold_policy_assignment_filter_field.py new file mode 100644 index 00000000..f9376779 --- /dev/null +++ b/box_sdk_gen/schemas/legal_hold_policy_assignment_filter_field.py @@ -0,0 +1,16 @@ +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class LegalHoldPolicyAssignmentFilterField(BaseObject): + def __init__(self, field: str, value: str, **kwargs): + """ + :param field: The ID of the metadata template field to filter on. + :type field: str + :param value: The value of the metadata template field to filter on. + :type value: str + """ + super().__init__(**kwargs) + self.field = field + self.value = value diff --git a/docs/legal_hold_policy_assignments.md b/docs/legal_hold_policy_assignments.md index c23119a4..0265272c 100644 --- a/docs/legal_hold_policy_assignments.md +++ b/docs/legal_hold_policy_assignments.md @@ -48,7 +48,7 @@ Returns a list of legal hold policy assignments. ## Assign legal hold policy -Assign a legal hold to an item type of: file, file version, folder, user, ownership, or interactions. +Assign a legal hold to an item type of: file, file version, folder, user, ownership, interactions, or metadata template. This operation is performed by calling function `create_legal_hold_policy_assignment`. @@ -72,6 +72,8 @@ client.legal_hold_policy_assignments.create_legal_hold_policy_assignment( - The ID of the policy to assign. - assign_to `CreateLegalHoldPolicyAssignmentAssignTo` - The item to assign the policy to. +- filter_fields `Optional[List[LegalHoldPolicyAssignmentFilterField]]` + - List of metadata template field filters. Only required when `assign_to.type` is `metadata_template`. - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request.