diff --git a/.codegen.json b/.codegen.json index 5ba0c78..20c21a8 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "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)