From 65f19b629455e5e402eb5bceec044901539e9223 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Jul 2025 03:11:48 -0700 Subject: [PATCH 1/4] feat: Hub items API (box/box-openapi#538) --- .codegen.json | 2 +- box_sdk_gen/client.py | 5 + box_sdk_gen/managers/__init__.py | 2 + box_sdk_gen/managers/hub_items.py | 177 +++++++++++++++++ box_sdk_gen/managers/hubs.py | 186 ++++++++++++++++++ box_sdk_gen/schemas/v2025_r0/__init__.py | 26 +++ .../v2025_r0/folder_reference_v2025_r0.py | 30 +++ .../schemas/v2025_r0/hub_action_v2025_r0.py | 8 + .../v2025_r0/hub_copy_request_v2025_r0.py | 24 +++ .../v2025_r0/hub_create_request_v2025_r0.py | 18 ++ .../hub_item_operation_result_v2025_r0.py | 44 +++++ .../v2025_r0/hub_item_operation_v2025_r0.py | 42 ++++ .../v2025_r0/hub_item_reference_v2025_r0.py | 17 ++ .../schemas/v2025_r0/hub_item_v2025_r0.py | 29 +++ .../hub_items_manage_request_v2025_r0.py | 23 +++ .../hub_items_manage_response_v2025_r0.py | 19 ++ .../schemas/v2025_r0/hub_items_v2025_r0.py | 34 ++++ .../v2025_r0/hub_update_request_v2025_r0.py | 42 ++++ .../v2025_r0/weblink_reference_v2025_r0.py | 30 +++ docs/README.md | 1 + docs/hub_items.md | 60 ++++++ docs/hubs.md | 101 ++++++++++ 22 files changed, 919 insertions(+), 1 deletion(-) create mode 100644 box_sdk_gen/managers/hub_items.py create mode 100644 box_sdk_gen/schemas/v2025_r0/folder_reference_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_action_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_copy_request_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_create_request_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_item_operation_result_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_item_operation_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_item_reference_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_item_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_items_manage_request_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_items_manage_response_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_items_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/hub_update_request_v2025_r0.py create mode 100644 box_sdk_gen/schemas/v2025_r0/weblink_reference_v2025_r0.py create mode 100644 docs/hub_items.md diff --git a/.codegen.json b/.codegen.json index 18b27f5..4f6ecdf 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "specHash": "719cda2", "version": "1.15.0" } +{ "engineHash": "fe7a2b2", "specHash": "7871ded", "version": "1.15.0" } diff --git a/box_sdk_gen/client.py b/box_sdk_gen/client.py index 212161e..514fde4 100644 --- a/box_sdk_gen/client.py +++ b/box_sdk_gen/client.py @@ -176,6 +176,8 @@ from box_sdk_gen.managers.hub_collaborations import HubCollaborationsManager +from box_sdk_gen.managers.hub_items import HubItemsManager + from box_sdk_gen.managers.shield_lists import ShieldListsManager from box_sdk_gen.networking.auth import Authentication @@ -427,6 +429,9 @@ def __init__(self, auth: Authentication, *, network_session: NetworkSession = No self.hub_collaborations = HubCollaborationsManager( auth=self.auth, network_session=self.network_session ) + self.hub_items = HubItemsManager( + auth=self.auth, network_session=self.network_session + ) self.shield_lists = ShieldListsManager( auth=self.auth, network_session=self.network_session ) diff --git a/box_sdk_gen/managers/__init__.py b/box_sdk_gen/managers/__init__.py index 181054b..e4eb3ab 100644 --- a/box_sdk_gen/managers/__init__.py +++ b/box_sdk_gen/managers/__init__.py @@ -150,4 +150,6 @@ from box_sdk_gen.managers.hub_collaborations import * +from box_sdk_gen.managers.hub_items import * + from box_sdk_gen.managers.shield_lists import * diff --git a/box_sdk_gen/managers/hub_items.py b/box_sdk_gen/managers/hub_items.py new file mode 100644 index 0000000..2bf89b0 --- /dev/null +++ b/box_sdk_gen/managers/hub_items.py @@ -0,0 +1,177 @@ +from typing import Optional + +from typing import Dict + +from box_sdk_gen.internal.utils import to_string + +from box_sdk_gen.serialization.json import deserialize + +from typing import List + +from box_sdk_gen.serialization.json import serialize + +from box_sdk_gen.networking.fetch_options import ResponseFormat + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_v2025_r0 import ( + HubItemOperationV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_items_v2025_r0 import HubItemsV2025R0 + +from box_sdk_gen.schemas.v2025_r0.client_error_v2025_r0 import ClientErrorV2025R0 + +from box_sdk_gen.parameters.v2025_r0.box_version_header_v2025_r0 import ( + BoxVersionHeaderV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_items_manage_response_v2025_r0 import ( + HubItemsManageResponseV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_items_manage_request_v2025_r0 import ( + HubItemsManageRequestV2025R0, +) + +from box_sdk_gen.box.errors import BoxSDKError + +from box_sdk_gen.networking.auth import Authentication + +from box_sdk_gen.networking.network import NetworkSession + +from box_sdk_gen.networking.fetch_options import FetchOptions + +from box_sdk_gen.networking.fetch_response import FetchResponse + +from box_sdk_gen.internal.utils import prepare_params + +from box_sdk_gen.internal.utils import to_string + +from box_sdk_gen.internal.utils import ByteStream + +from box_sdk_gen.serialization.json import sd_to_json + +from box_sdk_gen.serialization.json import SerializedData + + +class HubItemsManager: + def __init__( + self, + *, + auth: Optional[Authentication] = None, + network_session: NetworkSession = None + ): + if network_session is None: + network_session = NetworkSession() + self.auth = auth + self.network_session = network_session + + def get_hub_items_v2025_r0( + self, + hub_id: str, + *, + marker: Optional[str] = None, + limit: Optional[int] = None, + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> HubItemsV2025R0: + """ + Retrieves all items associated with a Hub. + :param hub_id: The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + :type hub_id: str + :param marker: Defines the position marker at which to begin returning results. This is + used when paginating using marker-based pagination. + + This requires `usemarker` to be set to `true`., defaults to None + :type marker: Optional[str], optional + :param limit: The maximum number of items to return per page., defaults to None + :type limit: Optional[int], optional + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 + :type box_version: BoxVersionHeaderV2025R0, 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 = {} + query_params_map: Dict[str, str] = prepare_params( + { + 'hub_id': to_string(hub_id), + 'marker': to_string(marker), + 'limit': to_string(limit), + } + ) + headers_map: Dict[str, str] = prepare_params( + {'box-version': to_string(box_version), **extra_headers} + ) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [self.network_session.base_urls.base_url, '/2.0/hub_items'] + ), + method='GET', + params=query_params_map, + headers=headers_map, + response_format=ResponseFormat.JSON, + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, HubItemsV2025R0) + + def create_hub_manage_item_v2025_r0( + self, + hub_id: str, + *, + operations: Optional[List[HubItemOperationV2025R0]] = None, + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> HubItemsManageResponseV2025R0: + """ + Adds and/or removes Hub items from a Hub. + :param hub_id: The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + Example: "12345" + :type hub_id: str + :param operations: List of operations to perform on Hub items., defaults to None + :type operations: Optional[List[HubItemOperationV2025R0]], optional + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 + :type box_version: BoxVersionHeaderV2025R0, 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 = {'operations': operations} + headers_map: Dict[str, str] = prepare_params( + {'box-version': to_string(box_version), **extra_headers} + ) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/hubs/', + to_string(hub_id), + '/manage_items', + ] + ), + method='POST', + headers=headers_map, + data=serialize(request_body), + content_type='application/json', + response_format=ResponseFormat.JSON, + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, HubItemsManageResponseV2025R0) diff --git a/box_sdk_gen/managers/hubs.py b/box_sdk_gen/managers/hubs.py index 8417df0..359c72b 100644 --- a/box_sdk_gen/managers/hubs.py +++ b/box_sdk_gen/managers/hubs.py @@ -8,6 +8,8 @@ from box_sdk_gen.serialization.json import deserialize +from box_sdk_gen.serialization.json import serialize + from box_sdk_gen.networking.fetch_options import ResponseFormat from box_sdk_gen.schemas.v2025_r0.hubs_v2025_r0 import HubsV2025R0 @@ -20,6 +22,16 @@ from box_sdk_gen.schemas.v2025_r0.hub_v2025_r0 import HubV2025R0 +from box_sdk_gen.schemas.v2025_r0.hub_create_request_v2025_r0 import ( + HubCreateRequestV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_update_request_v2025_r0 import ( + HubUpdateRequestV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_copy_request_v2025_r0 import HubCopyRequestV2025R0 + from box_sdk_gen.box.errors import BoxSDKError from box_sdk_gen.networking.auth import Authentication @@ -128,6 +140,45 @@ def get_hubs_v2025_r0( ) return deserialize(response.data, HubsV2025R0) + def create_hub_v2025_r0( + self, + title: str, + *, + description: Optional[str] = None, + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> HubV2025R0: + """ + Creates a new Hub. + :param title: Title of the Hub. It cannot be empty and should be less than 50 characters. + :type title: str + :param description: Description of the Hub., defaults to None + :type description: Optional[str], optional + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 + :type box_version: BoxVersionHeaderV2025R0, 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 = {'title': title, 'description': description} + headers_map: Dict[str, str] = prepare_params( + {'box-version': to_string(box_version), **extra_headers} + ) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join([self.network_session.base_urls.base_url, '/2.0/hubs']), + method='POST', + headers=headers_map, + data=serialize(request_body), + content_type='application/json', + response_format=ResponseFormat.JSON, + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, HubV2025R0) + def get_enterprise_hubs_v2025_r0( self, *, @@ -242,6 +293,82 @@ def get_hub_by_id_v2025_r0( ) return deserialize(response.data, HubV2025R0) + def update_hub_by_id_v2025_r0( + self, + hub_id: str, + *, + title: Optional[str] = None, + description: Optional[str] = None, + is_ai_enabled: Optional[bool] = None, + is_collaboration_restricted_to_enterprise: Optional[bool] = None, + can_non_owners_invite: Optional[bool] = None, + can_shared_link_be_created: Optional[bool] = None, + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> HubV2025R0: + """ + Updates a Hub. Can be used to change title, description, or Hub settings. + :param hub_id: The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + Example: "12345" + :type hub_id: str + :param title: Title of the Hub. It cannot be empty and should be less than 50 characters., defaults to None + :type title: Optional[str], optional + :param description: Description of the Hub., defaults to None + :type description: Optional[str], optional + :param is_ai_enabled: Indicates if AI features are enabled for the Hub., defaults to None + :type is_ai_enabled: Optional[bool], optional + :param is_collaboration_restricted_to_enterprise: Indicates if collaboration is restricted to the enterprise., defaults to None + :type is_collaboration_restricted_to_enterprise: Optional[bool], optional + :param can_non_owners_invite: Indicates if non-owners can invite others to the Hub., defaults to None + :type can_non_owners_invite: Optional[bool], optional + :param can_shared_link_be_created: Indicates if a shared link can be created for the Hub., defaults to None + :type can_shared_link_be_created: Optional[bool], optional + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 + :type box_version: BoxVersionHeaderV2025R0, 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 = { + 'title': title, + 'description': description, + 'is_ai_enabled': is_ai_enabled, + 'is_collaboration_restricted_to_enterprise': ( + is_collaboration_restricted_to_enterprise + ), + 'can_non_owners_invite': can_non_owners_invite, + 'can_shared_link_be_created': can_shared_link_be_created, + } + headers_map: Dict[str, str] = prepare_params( + {'box-version': to_string(box_version), **extra_headers} + ) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/hubs/', + to_string(hub_id), + ] + ), + method='PUT', + headers=headers_map, + data=serialize(request_body), + content_type='application/json', + response_format=ResponseFormat.JSON, + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, HubV2025R0) + def delete_hub_by_id_v2025_r0( self, hub_id: str, @@ -287,3 +414,62 @@ def delete_hub_by_id_v2025_r0( ) ) return None + + def create_hub_copy_v2025_r0( + self, + hub_id: str, + *, + title: Optional[str] = None, + description: Optional[str] = None, + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> HubV2025R0: + """ + Creates a copy of a Hub. + + The original Hub will not be modified. + + :param hub_id: The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + Example: "12345" + :type hub_id: str + :param title: Title of the Hub. It cannot be empty and should be less than 50 characters., defaults to None + :type title: Optional[str], optional + :param description: Description of the Hub., defaults to None + :type description: Optional[str], optional + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 + :type box_version: BoxVersionHeaderV2025R0, 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 = {'title': title, 'description': description} + headers_map: Dict[str, str] = prepare_params( + {'box-version': to_string(box_version), **extra_headers} + ) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/hubs/', + to_string(hub_id), + '/copy', + ] + ), + method='POST', + headers=headers_map, + data=serialize(request_body), + content_type='application/json', + response_format=ResponseFormat.JSON, + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, HubV2025R0) diff --git a/box_sdk_gen/schemas/v2025_r0/__init__.py b/box_sdk_gen/schemas/v2025_r0/__init__.py index 664355b..043b994 100644 --- a/box_sdk_gen/schemas/v2025_r0/__init__.py +++ b/box_sdk_gen/schemas/v2025_r0/__init__.py @@ -32,16 +32,30 @@ from box_sdk_gen.schemas.v2025_r0.doc_gen_batch_create_request_v2025_r0 import * +from box_sdk_gen.schemas.v2025_r0.folder_reference_v2025_r0 import * + from box_sdk_gen.schemas.v2025_r0.group_base_v2025_r0 import * from box_sdk_gen.schemas.v2025_r0.group_mini_v2025_r0 import * from box_sdk_gen.schemas.v2025_r0.hub_base_v2025_r0 import * +from box_sdk_gen.schemas.v2025_r0.hub_action_v2025_r0 import * + from box_sdk_gen.schemas.v2025_r0.hub_collaboration_create_request_v2025_r0 import * from box_sdk_gen.schemas.v2025_r0.hub_collaboration_update_request_v2025_r0 import * +from box_sdk_gen.schemas.v2025_r0.hub_copy_request_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_create_request_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_item_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_items_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_update_request_v2025_r0 import * + from box_sdk_gen.schemas.v2025_r0.shield_list_mini_v2025_r0 import * from box_sdk_gen.schemas.v2025_r0.shield_lists_v2025_r0 import * @@ -87,3 +101,15 @@ from box_sdk_gen.schemas.v2025_r0.doc_gen_job_full_v2025_r0 import * from box_sdk_gen.schemas.v2025_r0.doc_gen_jobs_full_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.weblink_reference_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_item_reference_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_result_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_items_manage_response_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_v2025_r0 import * + +from box_sdk_gen.schemas.v2025_r0.hub_items_manage_request_v2025_r0 import * diff --git a/box_sdk_gen/schemas/v2025_r0/folder_reference_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/folder_reference_v2025_r0.py new file mode 100644 index 0000000..c45fcca --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/folder_reference_v2025_r0.py @@ -0,0 +1,30 @@ +from enum import Enum + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class FolderReferenceV2025R0TypeField(str, Enum): + FOLDER = 'folder' + + +class FolderReferenceV2025R0(BaseObject): + _discriminator = 'type', {'folder'} + + def __init__( + self, + id: str, + *, + type: FolderReferenceV2025R0TypeField = FolderReferenceV2025R0TypeField.FOLDER, + **kwargs + ): + """ + :param id: ID of the folder. + :type id: str + :param type: The value will always be `folder`., defaults to FolderReferenceV2025R0TypeField.FOLDER + :type type: FolderReferenceV2025R0TypeField, optional + """ + super().__init__(**kwargs) + self.id = id + self.type = type diff --git a/box_sdk_gen/schemas/v2025_r0/hub_action_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_action_v2025_r0.py new file mode 100644 index 0000000..7e81ca8 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_action_v2025_r0.py @@ -0,0 +1,8 @@ +from enum import Enum + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubActionV2025R0(str, Enum): + ADD = 'add' + REMOVE = 'remove' diff --git a/box_sdk_gen/schemas/v2025_r0/hub_copy_request_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_copy_request_v2025_r0.py new file mode 100644 index 0000000..31da193 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_copy_request_v2025_r0.py @@ -0,0 +1,24 @@ +from typing import Optional + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubCopyRequestV2025R0(BaseObject): + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :param title: Title of the Hub. It cannot be empty and should be less than 50 characters., defaults to None + :type title: Optional[str], optional + :param description: Description of the Hub., defaults to None + :type description: Optional[str], optional + """ + super().__init__(**kwargs) + self.title = title + self.description = description diff --git a/box_sdk_gen/schemas/v2025_r0/hub_create_request_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_create_request_v2025_r0.py new file mode 100644 index 0000000..16b9cd3 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_create_request_v2025_r0.py @@ -0,0 +1,18 @@ +from typing import Optional + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubCreateRequestV2025R0(BaseObject): + def __init__(self, title: str, *, description: Optional[str] = None, **kwargs): + """ + :param title: Title of the Hub. It cannot be empty and should be less than 50 characters. + :type title: str + :param description: Description of the Hub., defaults to None + :type description: Optional[str], optional + """ + super().__init__(**kwargs) + self.title = title + self.description = description diff --git a/box_sdk_gen/schemas/v2025_r0/hub_item_operation_result_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_item_operation_result_v2025_r0.py new file mode 100644 index 0000000..f1423d2 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_item_operation_result_v2025_r0.py @@ -0,0 +1,44 @@ +from typing import Optional + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.v2025_r0.file_reference_v2025_r0 import FileReferenceV2025R0 + +from box_sdk_gen.schemas.v2025_r0.folder_reference_v2025_r0 import ( + FolderReferenceV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.weblink_reference_v2025_r0 import ( + WeblinkReferenceV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_item_reference_v2025_r0 import ( + HubItemReferenceV2025R0, +) + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubItemOperationResultV2025R0(BaseObject): + def __init__( + self, + *, + action: Optional[str] = None, + item: Optional[HubItemReferenceV2025R0] = None, + status: Optional[int] = None, + error: Optional[str] = None, + **kwargs + ): + """ + :param action: The action performed on the item., defaults to None + :type action: Optional[str], optional + :param status: The HTTP status code of the operation., defaults to None + :type status: Optional[int], optional + :param error: Error message if the operation failed., defaults to None + :type error: Optional[str], optional + """ + super().__init__(**kwargs) + self.action = action + self.item = item + self.status = status + self.error = error diff --git a/box_sdk_gen/schemas/v2025_r0/hub_item_operation_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_item_operation_v2025_r0.py new file mode 100644 index 0000000..3584f0d --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_item_operation_v2025_r0.py @@ -0,0 +1,42 @@ +from enum import Enum + +from typing import Union + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.v2025_r0.file_reference_v2025_r0 import FileReferenceV2025R0 + +from box_sdk_gen.schemas.v2025_r0.folder_reference_v2025_r0 import ( + FolderReferenceV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.weblink_reference_v2025_r0 import ( + WeblinkReferenceV2025R0, +) + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubItemOperationV2025R0ActionField(str, Enum): + ADD = 'add' + REMOVE = 'remove' + + +class HubItemOperationV2025R0(BaseObject): + def __init__( + self, + action: HubItemOperationV2025R0ActionField, + item: Union[ + FileReferenceV2025R0, FolderReferenceV2025R0, WeblinkReferenceV2025R0 + ], + **kwargs + ): + """ + :param action: The action to perform on a Hub item. + :type action: HubItemOperationV2025R0ActionField + :param item: Reference to an item that can be added to a Hub. + :type item: Union[FileReferenceV2025R0, FolderReferenceV2025R0, WeblinkReferenceV2025R0] + """ + super().__init__(**kwargs) + self.action = action + self.item = item diff --git a/box_sdk_gen/schemas/v2025_r0/hub_item_reference_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_item_reference_v2025_r0.py new file mode 100644 index 0000000..545cb70 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_item_reference_v2025_r0.py @@ -0,0 +1,17 @@ +from typing import Union + +from box_sdk_gen.schemas.v2025_r0.file_reference_v2025_r0 import FileReferenceV2025R0 + +from box_sdk_gen.schemas.v2025_r0.folder_reference_v2025_r0 import ( + FolderReferenceV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.weblink_reference_v2025_r0 import ( + WeblinkReferenceV2025R0, +) + +from box_sdk_gen.box.errors import BoxSDKError + +HubItemReferenceV2025R0 = Union[ + FileReferenceV2025R0, FolderReferenceV2025R0, WeblinkReferenceV2025R0 +] diff --git a/box_sdk_gen/schemas/v2025_r0/hub_item_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_item_v2025_r0.py new file mode 100644 index 0000000..f2fae55 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_item_v2025_r0.py @@ -0,0 +1,29 @@ +from enum import Enum + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubItemV2025R0TypeField(str, Enum): + FILE = 'file' + FOLDER = 'folder' + WEB_LINK = 'web_link' + + +class HubItemV2025R0(BaseObject): + _discriminator = 'type', {'file', 'folder', 'web_link'} + + def __init__(self, id: str, type: HubItemV2025R0TypeField, name: str, **kwargs): + """ + :param id: The unique identifier for this item. + :type id: str + :param type: The type of the item. + :type type: HubItemV2025R0TypeField + :param name: The name of the item. + :type name: str + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.name = name diff --git a/box_sdk_gen/schemas/v2025_r0/hub_items_manage_request_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_items_manage_request_v2025_r0.py new file mode 100644 index 0000000..563d250 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_items_manage_request_v2025_r0.py @@ -0,0 +1,23 @@ +from typing import Optional + +from typing import List + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_v2025_r0 import ( + HubItemOperationV2025R0, +) + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubItemsManageRequestV2025R0(BaseObject): + def __init__( + self, *, operations: Optional[List[HubItemOperationV2025R0]] = None, **kwargs + ): + """ + :param operations: List of operations to perform on Hub items., defaults to None + :type operations: Optional[List[HubItemOperationV2025R0]], optional + """ + super().__init__(**kwargs) + self.operations = operations diff --git a/box_sdk_gen/schemas/v2025_r0/hub_items_manage_response_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_items_manage_response_v2025_r0.py new file mode 100644 index 0000000..36747ce --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_items_manage_response_v2025_r0.py @@ -0,0 +1,19 @@ +from typing import List + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_result_v2025_r0 import ( + HubItemOperationResultV2025R0, +) + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubItemsManageResponseV2025R0(BaseObject): + def __init__(self, operations: List[HubItemOperationResultV2025R0], **kwargs): + """ + :param operations: List of operations performed on Hub items. + :type operations: List[HubItemOperationResultV2025R0] + """ + super().__init__(**kwargs) + self.operations = operations diff --git a/box_sdk_gen/schemas/v2025_r0/hub_items_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_items_v2025_r0.py new file mode 100644 index 0000000..652d1a1 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_items_v2025_r0.py @@ -0,0 +1,34 @@ +from typing import Optional + +from typing import List + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.v2025_r0.hub_item_v2025_r0 import HubItemV2025R0 + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubItemsV2025R0(BaseObject): + def __init__( + self, + *, + entries: Optional[List[HubItemV2025R0]] = None, + limit: Optional[int] = None, + next_marker: Optional[str] = None, + **kwargs + ): + """ + :param entries: A list of Hub items., defaults to None + :type entries: Optional[List[HubItemV2025R0]], optional + :param limit: The limit that was used for these entries. This will be the same as the + `limit` query parameter unless that value exceeded the maximum value + allowed. The maximum value varies by API., defaults to None + :type limit: Optional[int], optional + :param next_marker: The marker for the start of the next page of results., defaults to None + :type next_marker: Optional[str], optional + """ + super().__init__(**kwargs) + self.entries = entries + self.limit = limit + self.next_marker = next_marker diff --git a/box_sdk_gen/schemas/v2025_r0/hub_update_request_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/hub_update_request_v2025_r0.py new file mode 100644 index 0000000..dd75180 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/hub_update_request_v2025_r0.py @@ -0,0 +1,42 @@ +from typing import Optional + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class HubUpdateRequestV2025R0(BaseObject): + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + is_ai_enabled: Optional[bool] = None, + is_collaboration_restricted_to_enterprise: Optional[bool] = None, + can_non_owners_invite: Optional[bool] = None, + can_shared_link_be_created: Optional[bool] = None, + **kwargs + ): + """ + :param title: Title of the Hub. It cannot be empty and should be less than 50 characters., defaults to None + :type title: Optional[str], optional + :param description: Description of the Hub., defaults to None + :type description: Optional[str], optional + :param is_ai_enabled: Indicates if AI features are enabled for the Hub., defaults to None + :type is_ai_enabled: Optional[bool], optional + :param is_collaboration_restricted_to_enterprise: Indicates if collaboration is restricted to the enterprise., defaults to None + :type is_collaboration_restricted_to_enterprise: Optional[bool], optional + :param can_non_owners_invite: Indicates if non-owners can invite others to the Hub., defaults to None + :type can_non_owners_invite: Optional[bool], optional + :param can_shared_link_be_created: Indicates if a shared link can be created for the Hub., defaults to None + :type can_shared_link_be_created: Optional[bool], optional + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.is_ai_enabled = is_ai_enabled + self.is_collaboration_restricted_to_enterprise = ( + is_collaboration_restricted_to_enterprise + ) + self.can_non_owners_invite = can_non_owners_invite + self.can_shared_link_be_created = can_shared_link_be_created diff --git a/box_sdk_gen/schemas/v2025_r0/weblink_reference_v2025_r0.py b/box_sdk_gen/schemas/v2025_r0/weblink_reference_v2025_r0.py new file mode 100644 index 0000000..1e767a5 --- /dev/null +++ b/box_sdk_gen/schemas/v2025_r0/weblink_reference_v2025_r0.py @@ -0,0 +1,30 @@ +from enum import Enum + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class WeblinkReferenceV2025R0TypeField(str, Enum): + WEBLINK = 'weblink' + + +class WeblinkReferenceV2025R0(BaseObject): + _discriminator = 'type', {'weblink'} + + def __init__( + self, + id: str, + *, + type: WeblinkReferenceV2025R0TypeField = WeblinkReferenceV2025R0TypeField.WEBLINK, + **kwargs + ): + """ + :param id: ID of the weblink. + :type id: str + :param type: The value will always be `weblink`., defaults to WeblinkReferenceV2025R0TypeField.WEBLINK + :type type: WeblinkReferenceV2025R0TypeField, optional + """ + super().__init__(**kwargs) + self.id = id + self.type = type diff --git a/docs/README.md b/docs/README.md index fc01298..d579002 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,6 +37,7 @@ the SDK are available by topic: - [Folders](folders.md) - [Groups](groups.md) - [Hub collaborations](hub_collaborations.md) +- [Hub items](hub_items.md) - [Hubs](hubs.md) - [Integration mappings](integration_mappings.md) - [Invites](invites.md) diff --git a/docs/hub_items.md b/docs/hub_items.md new file mode 100644 index 0000000..7362308 --- /dev/null +++ b/docs/hub_items.md @@ -0,0 +1,60 @@ +# HubItemsManager + +- [Get hub items](#get-hub-items) +- [Manage hub items](#manage-hub-items) + +## Get hub items + +Retrieves all items associated with a Hub. + +This operation is performed by calling function `get_hub_items_v2025_r0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/get-hub-items/). + +_Currently we don't have an example for calling `get_hub_items_v2025_r0` in integration tests_ + +### Arguments + +- hub_id `str` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. +- marker `Optional[str]` + - Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires `usemarker` to be set to `true`. +- limit `Optional[int]` + - The maximum number of items to return per page. +- box_version `BoxVersionHeaderV2025R0` + - Version header. +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + +### Returns + +This function returns a value of type `HubItemsV2025R0`. + +Retrieves the items associated with the specified Hub. + +## Manage hub items + +Adds and/or removes Hub items from a Hub. + +This operation is performed by calling function `create_hub_manage_item_v2025_r0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-hubs-id-manage-items/). + +_Currently we don't have an example for calling `create_hub_manage_item_v2025_r0` in integration tests_ + +### Arguments + +- hub_id `str` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. Example: "12345" +- operations `Optional[List[HubItemOperationV2025R0]]` + - List of operations to perform on Hub items. +- box_version `BoxVersionHeaderV2025R0` + - Version header. +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + +### Returns + +This function returns a value of type `HubItemsManageResponseV2025R0`. diff --git a/docs/hubs.md b/docs/hubs.md index 784e818..4216d08 100644 --- a/docs/hubs.md +++ b/docs/hubs.md @@ -1,9 +1,12 @@ # HubsManager - [List all hubs](#list-all-hubs) +- [Create hub](#create-hub) - [List all hubs for requesting enterprise](#list-all-hubs-for-requesting-enterprise) - [Get hub information by ID](#get-hub-information-by-id) +- [Update hub information by ID](#update-hub-information-by-id) - [Delete hub](#delete-hub) +- [Copy hub](#copy-hub) ## List all hubs @@ -47,6 +50,34 @@ This function returns a value of type `HubsV2025R0`. Returns all hubs for the given user or enterprise. +## Create hub + +Creates a new Hub. + +This operation is performed by calling function `create_hub_v2025_r0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-hubs/). + +_Currently we don't have an example for calling `create_hub_v2025_r0` in integration tests_ + +### Arguments + +- title `str` + - Title of the Hub. It cannot be empty and should be less than 50 characters. +- description `Optional[str]` + - Description of the Hub. +- box_version `BoxVersionHeaderV2025R0` + - Version header. +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + +### Returns + +This function returns a value of type `HubV2025R0`. + +Returns a new Hub object. + ## List all hubs for requesting enterprise Retrieves all hubs for a given enterprise. @@ -120,6 +151,44 @@ This function returns a value of type `HubV2025R0`. Returns a hub object. +## Update hub information by ID + +Updates a Hub. Can be used to change title, description, or Hub settings. + +This operation is performed by calling function `update_hub_by_id_v2025_r0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/put-hubs-id/). + +_Currently we don't have an example for calling `update_hub_by_id_v2025_r0` in integration tests_ + +### Arguments + +- hub_id `str` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. Example: "12345" +- title `Optional[str]` + - Title of the Hub. It cannot be empty and should be less than 50 characters. +- description `Optional[str]` + - Description of the Hub. +- is_ai_enabled `Optional[bool]` + - Indicates if AI features are enabled for the Hub. +- is_collaboration_restricted_to_enterprise `Optional[bool]` + - Indicates if collaboration is restricted to the enterprise. +- can_non_owners_invite `Optional[bool]` + - Indicates if non-owners can invite others to the Hub. +- can_shared_link_be_created `Optional[bool]` + - Indicates if a shared link can be created for the Hub. +- box_version `BoxVersionHeaderV2025R0` + - Version header. +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + +### Returns + +This function returns a value of type `HubV2025R0`. + +Returns a Hub object. + ## Delete hub Deletes a single hub. @@ -150,3 +219,35 @@ This function returns a value of type `None`. A blank response is returned if the hub was successfully deleted. + +## Copy hub + +Creates a copy of a Hub. + +The original Hub will not be modified. + +This operation is performed by calling function `create_hub_copy_v2025_r0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-hubs-id-copy/). + +_Currently we don't have an example for calling `create_hub_copy_v2025_r0` in integration tests_ + +### Arguments + +- hub_id `str` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. Example: "12345" +- title `Optional[str]` + - Title of the Hub. It cannot be empty and should be less than 50 characters. +- description `Optional[str]` + - Description of the Hub. +- box_version `BoxVersionHeaderV2025R0` + - Version header. +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + +### Returns + +This function returns a value of type `HubV2025R0`. + +Returns a new Hub object. From 7dece9744404c040d9a41929541cbb1e19ad67e5 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Jul 2025 06:37:47 -0700 Subject: [PATCH 2/4] fix: Error at 'Create metadata instance on file' box/box-openapi#393 (box/box-openapi#539) --- .codegen.json | 2 +- box_sdk_gen/managers/file_metadata.py | 2 ++ box_sdk_gen/managers/folder_metadata.py | 2 ++ box_sdk_gen/schemas/__init__.py | 2 ++ box_sdk_gen/schemas/metadata_error.py | 29 +++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 box_sdk_gen/schemas/metadata_error.py diff --git a/.codegen.json b/.codegen.json index 4f6ecdf..5ba0c78 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "specHash": "7871ded", "version": "1.15.0" } +{ "engineHash": "fe7a2b2", "specHash": "eaa9cf0", "version": "1.15.0" } diff --git a/box_sdk_gen/managers/file_metadata.py b/box_sdk_gen/managers/file_metadata.py index a61cfab..8dc0577 100644 --- a/box_sdk_gen/managers/file_metadata.py +++ b/box_sdk_gen/managers/file_metadata.py @@ -22,6 +22,8 @@ from box_sdk_gen.schemas.metadata_full import MetadataFull +from box_sdk_gen.schemas.metadata_error import MetadataError + from box_sdk_gen.schemas.metadata_instance_value import MetadataInstanceValue from box_sdk_gen.box.errors import BoxSDKError diff --git a/box_sdk_gen/managers/folder_metadata.py b/box_sdk_gen/managers/folder_metadata.py index 0cea26e..602effe 100644 --- a/box_sdk_gen/managers/folder_metadata.py +++ b/box_sdk_gen/managers/folder_metadata.py @@ -22,6 +22,8 @@ from box_sdk_gen.schemas.metadata_full import MetadataFull +from box_sdk_gen.schemas.metadata_error import MetadataError + from box_sdk_gen.schemas.metadata_instance_value import MetadataInstanceValue from box_sdk_gen.box.errors import BoxSDKError diff --git a/box_sdk_gen/schemas/__init__.py b/box_sdk_gen/schemas/__init__.py index e3beed4..8c051af 100644 --- a/box_sdk_gen/schemas/__init__.py +++ b/box_sdk_gen/schemas/__init__.py @@ -194,6 +194,8 @@ from box_sdk_gen.schemas.metadata_cascade_policies import * +from box_sdk_gen.schemas.metadata_error import * + from box_sdk_gen.schemas.metadata_field_filter_date_range import * from box_sdk_gen.schemas.metadata_field_filter_float_range import * diff --git a/box_sdk_gen/schemas/metadata_error.py b/box_sdk_gen/schemas/metadata_error.py new file mode 100644 index 0000000..24d5ab1 --- /dev/null +++ b/box_sdk_gen/schemas/metadata_error.py @@ -0,0 +1,29 @@ +from typing import Optional + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class MetadataError(BaseObject): + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + request_id: Optional[str] = None, + **kwargs + ): + """ + :param code: A Box-specific error code., defaults to None + :type code: Optional[str], optional + :param message: A short message describing the error., defaults to None + :type message: Optional[str], optional + :param request_id: A unique identifier for this response, which can be used + when contacting Box support., defaults to None + :type request_id: Optional[str], optional + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.request_id = request_id From 7766d055ceb4aac51c400c1d5e3ff79bfb6e2b8c Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Jul 2025 10:41:48 -0700 Subject: [PATCH 3/4] chore: Update .codegen.json with commit hash of codegen and openapi spec --- .codegen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codegen.json b/.codegen.json index 5ba0c78..a8db1ca 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "specHash": "eaa9cf0", "version": "1.15.0" } +{ "engineHash": "2ecc24a", "specHash": "eaa9cf0", "version": "1.15.0" } From 4a89217e83af55f751560834789e848f7dce8e34 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 18 Jul 2025 02:12:42 -0700 Subject: [PATCH 4/4] test: add tests for new hub endpoints and hub items (box/box-codegen#766) --- .codegen.json | 2 +- box_sdk_gen/managers/hub_items.py | 2 +- box_sdk_gen/managers/hubs.py | 2 +- docs/hub_items.md | 22 +++++++- docs/hubs.md | 28 ++++++++-- test/hub_items.py | 93 +++++++++++++++++++++++++++++++ test/hubs.py | 70 ++++++++++++++++------- 7 files changed, 188 insertions(+), 31 deletions(-) create mode 100644 test/hub_items.py diff --git a/.codegen.json b/.codegen.json index a8db1ca..20c21a8 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2ecc24a", "specHash": "eaa9cf0", "version": "1.15.0" } +{ "engineHash": "66d6f32", "specHash": "eaa9cf0", "version": "1.15.0" } diff --git a/box_sdk_gen/managers/hub_items.py b/box_sdk_gen/managers/hub_items.py index 2bf89b0..4ad4e44 100644 --- a/box_sdk_gen/managers/hub_items.py +++ b/box_sdk_gen/managers/hub_items.py @@ -123,7 +123,7 @@ def get_hub_items_v2025_r0( ) return deserialize(response.data, HubItemsV2025R0) - def create_hub_manage_item_v2025_r0( + def manage_hub_items_v2025_r0( self, hub_id: str, *, diff --git a/box_sdk_gen/managers/hubs.py b/box_sdk_gen/managers/hubs.py index 359c72b..549ad35 100644 --- a/box_sdk_gen/managers/hubs.py +++ b/box_sdk_gen/managers/hubs.py @@ -415,7 +415,7 @@ def delete_hub_by_id_v2025_r0( ) return None - def create_hub_copy_v2025_r0( + def copy_hub_v2025_r0( self, hub_id: str, *, diff --git a/docs/hub_items.md b/docs/hub_items.md index 7362308..cca06ab 100644 --- a/docs/hub_items.md +++ b/docs/hub_items.md @@ -12,7 +12,11 @@ This operation is performed by calling function `get_hub_items_v2025_r0`. See the endpoint docs at [API Reference](https://developer.box.com/reference/v2025.0/get-hub-items/). -_Currently we don't have an example for calling `get_hub_items_v2025_r0` in integration tests_ + + +```python +client.hub_items.get_hub_items_v2025_r0(created_hub.id) +``` ### Arguments @@ -37,12 +41,24 @@ Retrieves the items associated with the specified Hub. Adds and/or removes Hub items from a Hub. -This operation is performed by calling function `create_hub_manage_item_v2025_r0`. +This operation is performed by calling function `manage_hub_items_v2025_r0`. See the endpoint docs at [API Reference](https://developer.box.com/reference/v2025.0/post-hubs-id-manage-items/). -_Currently we don't have an example for calling `create_hub_manage_item_v2025_r0` in integration tests_ + + +```python +client.hub_items.manage_hub_items_v2025_r0( + created_hub.id, + operations=[ + HubItemOperationV2025R0( + action=HubItemOperationV2025R0ActionField.ADD, + item=FolderReferenceV2025R0(id=folder.id), + ) + ], +) +``` ### Arguments diff --git a/docs/hubs.md b/docs/hubs.md index 4216d08..c31652d 100644 --- a/docs/hubs.md +++ b/docs/hubs.md @@ -59,7 +59,11 @@ This operation is performed by calling function `create_hub_v2025_r0`. See the endpoint docs at [API Reference](https://developer.box.com/reference/v2025.0/post-hubs/). -_Currently we don't have an example for calling `create_hub_v2025_r0` in integration tests_ + + +```python +client.hubs.create_hub_v2025_r0(hub_title, description=hub_description) +``` ### Arguments @@ -133,7 +137,7 @@ See the endpoint docs at ```python -client.hubs.get_hub_by_id_v2025_r0(user_hub.id) +client.hubs.get_hub_by_id_v2025_r0(hub_id) ``` ### Arguments @@ -160,7 +164,13 @@ This operation is performed by calling function `update_hub_by_id_v2025_r0`. See the endpoint docs at [API Reference](https://developer.box.com/reference/v2025.0/put-hubs-id/). -_Currently we don't have an example for calling `update_hub_by_id_v2025_r0` in integration tests_ + + +```python +client.hubs.update_hub_by_id_v2025_r0( + hub_id, title=new_hub_title, description=new_hub_description +) +``` ### Arguments @@ -201,7 +211,7 @@ See the endpoint docs at ```python -client.hubs.delete_hub_by_id_v2025_r0(hub.id) +client.hubs.delete_hub_by_id_v2025_r0(hub_id) ``` ### Arguments @@ -226,12 +236,18 @@ Creates a copy of a Hub. The original Hub will not be modified. -This operation is performed by calling function `create_hub_copy_v2025_r0`. +This operation is performed by calling function `copy_hub_v2025_r0`. See the endpoint docs at [API Reference](https://developer.box.com/reference/v2025.0/post-hubs-id-copy/). -_Currently we don't have an example for calling `create_hub_copy_v2025_r0` in integration tests_ + + +```python +client.hubs.copy_hub_v2025_r0( + created_hub.id, title=copied_hub_title, description=copied_hub_description +) +``` ### Arguments diff --git a/test/hub_items.py b/test/hub_items.py new file mode 100644 index 0000000..8e84392 --- /dev/null +++ b/test/hub_items.py @@ -0,0 +1,93 @@ +from box_sdk_gen.internal.utils import to_string + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas.folder_full import FolderFull + +from box_sdk_gen.managers.folders import CreateFolderParent + +from box_sdk_gen.schemas.v2025_r0.hub_v2025_r0 import HubV2025R0 + +from box_sdk_gen.schemas.v2025_r0.hub_items_v2025_r0 import HubItemsV2025R0 + +from box_sdk_gen.schemas.v2025_r0.hub_items_manage_response_v2025_r0 import ( + HubItemsManageResponseV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_v2025_r0 import ( + HubItemOperationV2025R0, +) + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_v2025_r0 import ( + HubItemOperationV2025R0ActionField, +) + +from box_sdk_gen.schemas.v2025_r0.hub_item_operation_result_v2025_r0 import ( + HubItemOperationResultV2025R0, +) + +from test.commons import get_default_client_with_user_subject + +from box_sdk_gen.internal.utils import get_env_var + +from box_sdk_gen.internal.utils import get_uuid + +from box_sdk_gen.schemas.v2025_r0.folder_reference_v2025_r0 import ( + FolderReferenceV2025R0, +) + +client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID')) + + +def testCreateDeleteGetHubItems(): + hub_title: str = get_uuid() + folder: FolderFull = client.folders.create_folder( + get_uuid(), CreateFolderParent(id='0') + ) + created_hub: HubV2025R0 = client.hubs.create_hub_v2025_r0(hub_title) + hub_items_before_add: HubItemsV2025R0 = client.hub_items.get_hub_items_v2025_r0( + created_hub.id + ) + assert len(hub_items_before_add.entries) == 0 + added_hub_items: HubItemsManageResponseV2025R0 = ( + client.hub_items.manage_hub_items_v2025_r0( + created_hub.id, + operations=[ + HubItemOperationV2025R0( + action=HubItemOperationV2025R0ActionField.ADD, + item=FolderReferenceV2025R0(id=folder.id), + ) + ], + ) + ) + added_hub_item: HubItemOperationResultV2025R0 = added_hub_items.operations[0] + assert to_string(added_hub_item.action) == 'add' + assert added_hub_item.status == 200 + assert added_hub_item.item.id == folder.id + assert added_hub_item.item.type == 'folder' + hub_items_after_add: HubItemsV2025R0 = client.hub_items.get_hub_items_v2025_r0( + created_hub.id + ) + assert len(hub_items_after_add.entries) == 1 + removed_hub_items: HubItemsManageResponseV2025R0 = ( + client.hub_items.manage_hub_items_v2025_r0( + created_hub.id, + operations=[ + HubItemOperationV2025R0( + action=HubItemOperationV2025R0ActionField.REMOVE, + item=FolderReferenceV2025R0(id=folder.id), + ) + ], + ) + ) + removed_hub_item: HubItemOperationResultV2025R0 = removed_hub_items.operations[0] + assert to_string(removed_hub_item.action) == 'remove' + assert removed_hub_item.status == 200 + assert removed_hub_item.item.id == folder.id + assert removed_hub_item.item.type == 'folder' + hub_items_after_remove: HubItemsV2025R0 = client.hub_items.get_hub_items_v2025_r0( + created_hub.id + ) + assert len(hub_items_after_remove.entries) == 0 + client.hubs.delete_hub_by_id_v2025_r0(created_hub.id) + client.folders.delete_folder_by_id(folder.id) diff --git a/test/hubs.py b/test/hubs.py index e11dd42..bc61cf7 100644 --- a/test/hubs.py +++ b/test/hubs.py @@ -1,42 +1,74 @@ from box_sdk_gen.internal.utils import to_string +import pytest + from box_sdk_gen.client import BoxClient +from box_sdk_gen.schemas.v2025_r0.hub_v2025_r0 import HubV2025R0 + from box_sdk_gen.schemas.v2025_r0.hubs_v2025_r0 import HubsV2025R0 from box_sdk_gen.managers.hubs import GetHubsV2025R0Direction -from box_sdk_gen.schemas.v2025_r0.hub_v2025_r0 import HubV2025R0 - from box_sdk_gen.managers.hubs import GetEnterpriseHubsV2025R0Direction from test.commons import get_default_client_with_user_subject from box_sdk_gen.internal.utils import get_env_var +from box_sdk_gen.internal.utils import get_uuid + client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID')) -def testGetAndDeleteHubs(): - user_hubs: HubsV2025R0 = client.hubs.get_hubs_v2025_r0( +def testCreateUpdateGetAndDeleteHubs(): + hub_title: str = get_uuid() + hub_description: str = 'new Hub description' + created_hub: HubV2025R0 = client.hubs.create_hub_v2025_r0( + hub_title, description=hub_description + ) + assert created_hub.title == hub_title + assert created_hub.description == hub_description + assert to_string(created_hub.type) == 'hubs' + hub_id: str = created_hub.id + users_hubs: HubsV2025R0 = client.hubs.get_hubs_v2025_r0( scope='all', sort='name', direction=GetHubsV2025R0Direction.ASC ) - assert len(user_hubs.entries) > 0 - user_hub: HubV2025R0 = user_hubs.entries[0] - assert not user_hub.title == '' - assert not user_hub.id == '' - assert to_string(user_hub.type) == 'hubs' + assert len(users_hubs.entries) > 0 enterprise_hubs: HubsV2025R0 = client.hubs.get_enterprise_hubs_v2025_r0( sort='name', direction=GetEnterpriseHubsV2025R0Direction.ASC ) assert len(enterprise_hubs.entries) > 0 - enterprise_hub: HubV2025R0 = enterprise_hubs.entries[0] - assert not enterprise_hub.title == '' - assert not enterprise_hub.id == '' - assert to_string(enterprise_hub.type) == 'hubs' - hub: HubV2025R0 = client.hubs.get_hub_by_id_v2025_r0(user_hub.id) - assert not hub.title == '' - assert not hub.id == '' - assert to_string(hub.type) == 'hubs' - if len(enterprise_hubs.entries) > 10: - client.hubs.delete_hub_by_id_v2025_r0(hub.id) + hub_by_id: HubV2025R0 = client.hubs.get_hub_by_id_v2025_r0(hub_id) + assert hub_by_id.id == hub_id + assert hub_by_id.title == hub_title + assert hub_by_id.description == hub_description + assert to_string(hub_by_id.type) == 'hubs' + new_hub_title: str = get_uuid() + new_hub_description: str = 'updated Hub description' + updated_hub: HubV2025R0 = client.hubs.update_hub_by_id_v2025_r0( + hub_id, title=new_hub_title, description=new_hub_description + ) + assert updated_hub.title == new_hub_title + assert updated_hub.description == new_hub_description + client.hubs.delete_hub_by_id_v2025_r0(hub_id) + with pytest.raises(Exception): + client.hubs.delete_hub_by_id_v2025_r0(hub_id) + + +def copyHub(): + hub_title: str = get_uuid() + hub_description: str = 'new Hub description' + created_hub: HubV2025R0 = client.hubs.create_hub_v2025_r0( + hub_title, description=hub_description + ) + copied_hub_title: str = get_uuid() + copied_hub_description: str = 'copied Hub description' + copied_hub: HubV2025R0 = client.hubs.copy_hub_v2025_r0( + created_hub.id, title=copied_hub_title, description=copied_hub_description + ) + assert not copied_hub.id == created_hub.id + assert copied_hub.title == copied_hub_title + assert copied_hub.description == copied_hub_description + client.hubs.delete_hub_by_id_v2025_r0(created_hub.id) + client.hubs.delete_hub_by_id_v2025_r0(copied_hub.id)