From 1495a055bffe9a0cd5c8cc14950053f8eacaaac8 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 21 Feb 2025 03:13:56 -0800 Subject: [PATCH 01/18] docs: Documentation for Java SDK (box/box-codegen#664) --- .codegen.json | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.codegen.json b/.codegen.json index 1e36a3eb..835176ae 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "22f85cc", "specHash": "f20ba3f", "version": "1.12.0" } +{ "engineHash": "5c674a3", "specHash": "f20ba3f", "version": "1.12.0" } diff --git a/README.md b/README.md index f3066265..cf4a1253 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ “box-dev-logo”

-# Box Python SDK GENERATED +# Box Python SDK Gen [![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges) ![build](https://github.com/box/box-python-sdk-gen/actions/workflows/build.yml/badge.svg) @@ -28,7 +28,7 @@ Embrace the new generation of Box SDKs and unlock the full potential of the Box -- [Box Python SDK GENERATED](#box-python-sdk-generated) +- [Box Python SDK Gen](#box-python-sdk-gen) - [Table of contents](#table-of-contents) - [Installing](#installing) - [Getting Started](#getting-started) From 0806a401dc19a5f50b2f7dfecc7fe0dd1447eb87 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 21 Feb 2025 05:23:44 -0800 Subject: [PATCH 02/18] docs: remove beta tag for AI extract endpoints (box/box-openapi#511) --- .codegen.json | 2 +- box_sdk_gen/managers/ai.py | 30 +++++++++++++----------------- box_sdk_gen/schemas/ai_ask.py | 24 ++++++++++-------------- docs/ai.md | 4 ++-- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/.codegen.json b/.codegen.json index 835176ae..42063025 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "5c674a3", "specHash": "f20ba3f", "version": "1.12.0" } +{ "engineHash": "5c674a3", "specHash": "137a375", "version": "1.12.0" } diff --git a/box_sdk_gen/managers/ai.py b/box_sdk_gen/managers/ai.py index 554e346d..d14af870 100644 --- a/box_sdk_gen/managers/ai.py +++ b/box_sdk_gen/managers/ai.py @@ -226,23 +226,19 @@ def create_ai_ask( extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> Optional[AiResponseFull]: """ - Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context. - :param mode: The mode specifies if this request is for a single or multiple items. If you select `single_item_qa` the `items` array can have one element only. Selecting `multiple_item_qa` allows you to provide up to 25 items. - :type mode: CreateAiAskMode - :param prompt: The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters. - :type prompt: str - :param items: The items to be processed by the LLM, often files. - - **Note**: Box AI handles documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. - If the file size exceeds 1MB, the first 1MB of text representation will be processed. - If you set `mode` parameter to `single_item_qa`, the `items` array can have one element only. - :type items: List[AiItemAsk] - :param dialogue_history: The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response., defaults to None - :type dialogue_history: Optional[List[AiDialogueHistory]], optional - :param include_citations: A flag to indicate whether citations should be returned., defaults to None - :type include_citations: Optional[bool], 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 + Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context. + :param mode: Box AI handles text documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. If the text file size exceeds 1MB, the first 1MB of text representation will be processed. Box AI handles image documents with a resolution of 1024 x 1024 pixels, with a maximum of 5 images or 5 pages for multi-page images. If the number of image or image pages exceeds 5, the first 5 images or pages will be processed. If you set mode parameter to `single_item_qa`, the items array can have one element only. Currently Box AI does not support multi-modal requests. If both images and text are sent Box AI will only process the text. + :type mode: CreateAiAskMode + :param prompt: The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters. + :type prompt: str + :param items: The items to be processed by the LLM, often files. + :type items: List[AiItemAsk] + :param dialogue_history: The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response., defaults to None + :type dialogue_history: Optional[List[AiDialogueHistory]], optional + :param include_citations: A flag to indicate whether citations should be returned., defaults to None + :type include_citations: Optional[bool], 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 = {} diff --git a/box_sdk_gen/schemas/ai_ask.py b/box_sdk_gen/schemas/ai_ask.py index 46ba3635..321a7732 100644 --- a/box_sdk_gen/schemas/ai_ask.py +++ b/box_sdk_gen/schemas/ai_ask.py @@ -37,20 +37,16 @@ def __init__( **kwargs ): """ - :param mode: The mode specifies if this request is for a single or multiple items. If you select `single_item_qa` the `items` array can have one element only. Selecting `multiple_item_qa` allows you to provide up to 25 items. - :type mode: AiAskModeField - :param prompt: The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters. - :type prompt: str - :param items: The items to be processed by the LLM, often files. - - **Note**: Box AI handles documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. - If the file size exceeds 1MB, the first 1MB of text representation will be processed. - If you set `mode` parameter to `single_item_qa`, the `items` array can have one element only. - :type items: List[AiItemAsk] - :param dialogue_history: The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response., defaults to None - :type dialogue_history: Optional[List[AiDialogueHistory]], optional - :param include_citations: A flag to indicate whether citations should be returned., defaults to None - :type include_citations: Optional[bool], optional + :param mode: Box AI handles text documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. If the text file size exceeds 1MB, the first 1MB of text representation will be processed. Box AI handles image documents with a resolution of 1024 x 1024 pixels, with a maximum of 5 images or 5 pages for multi-page images. If the number of image or image pages exceeds 5, the first 5 images or pages will be processed. If you set mode parameter to `single_item_qa`, the items array can have one element only. Currently Box AI does not support multi-modal requests. If both images and text are sent Box AI will only process the text. + :type mode: AiAskModeField + :param prompt: The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters. + :type prompt: str + :param items: The items to be processed by the LLM, often files. + :type items: List[AiItemAsk] + :param dialogue_history: The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response., defaults to None + :type dialogue_history: Optional[List[AiDialogueHistory]], optional + :param include_citations: A flag to indicate whether citations should be returned., defaults to None + :type include_citations: Optional[bool], optional """ super().__init__(**kwargs) self.mode = mode diff --git a/docs/ai.md b/docs/ai.md index 5cbeb2d6..ab25257a 100644 --- a/docs/ai.md +++ b/docs/ai.md @@ -35,11 +35,11 @@ client.ai.create_ai_ask( ### Arguments - mode `CreateAiAskMode` - - The mode specifies if this request is for a single or multiple items. If you select `single_item_qa` the `items` array can have one element only. Selecting `multiple_item_qa` allows you to provide up to 25 items. + - Box AI handles text documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. If the text file size exceeds 1MB, the first 1MB of text representation will be processed. Box AI handles image documents with a resolution of 1024 x 1024 pixels, with a maximum of 5 images or 5 pages for multi-page images. If the number of image or image pages exceeds 5, the first 5 images or pages will be processed. If you set mode parameter to `single_item_qa`, the items array can have one element only. Currently Box AI does not support multi-modal requests. If both images and text are sent Box AI will only process the text. - prompt `str` - The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters. - items `List[AiItemAsk]` - - The items to be processed by the LLM, often files. **Note**: Box AI handles documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. If the file size exceeds 1MB, the first 1MB of text representation will be processed. If you set `mode` parameter to `single_item_qa`, the `items` array can have one element only. + - The items to be processed by the LLM, often files. - dialogue_history `Optional[List[AiDialogueHistory]]` - The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response. - include_citations `Optional[bool]` From 5305463a91bed48b7ea4cdbbc491856e203eb9eb Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 21 Feb 2025 05:25:33 -0800 Subject: [PATCH 03/18] 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 42063025..718862e4 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "5c674a3", "specHash": "137a375", "version": "1.12.0" } +{ "engineHash": "5c674a3", "specHash": "06fc5f7", "version": "1.12.0" } From 3fa0476bbe1671bd4fd21d02634ed608e2c2fc4d Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Mon, 24 Feb 2025 01:10:58 -0800 Subject: [PATCH 04/18] 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 718862e4..35499d81 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "5c674a3", "specHash": "06fc5f7", "version": "1.12.0" } +{ "engineHash": "89ce9ce", "specHash": "06fc5f7", "version": "1.12.0" } From 680206cb794a28a3612e6ba1b29c9a2d7db61e8f Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Mon, 24 Feb 2025 05:08:48 -0800 Subject: [PATCH 05/18] test: reorder function calls to fix test samples (box/box-codegen#666) --- .codegen.json | 2 +- docs/legal_hold_policies.md | 8 +++-- docs/metadata_templates.md | 31 +++++++++++++++++++- docs/search.md | 18 ++++++++++-- test/legal_hold_policies.py | 54 +++++++++++++++++----------------- test/metadata_templates.py | 58 +++++++++++++++++++++++++++++++++---- test/search.py | 50 ++++++++++++++++---------------- 7 files changed, 158 insertions(+), 63 deletions(-) diff --git a/.codegen.json b/.codegen.json index 35499d81..3fe1b974 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "89ce9ce", "specHash": "06fc5f7", "version": "1.12.0" } +{ "engineHash": "ef00939", "specHash": "06fc5f7", "version": "1.12.0" } diff --git a/docs/legal_hold_policies.md b/docs/legal_hold_policies.md index 81a37a57..0c26f138 100644 --- a/docs/legal_hold_policies.md +++ b/docs/legal_hold_policies.md @@ -54,7 +54,11 @@ See the endpoint docs at ```python client.legal_hold_policies.create_legal_hold_policy( - legal_hold_policy_name, description=legal_hold_description, is_ongoing=True + legal_hold_policy_name, + description=legal_hold_description, + filter_started_at=filter_started_at, + filter_ended_at=filter_ended_at, + is_ongoing=False, ) ``` @@ -158,7 +162,7 @@ See the endpoint docs at ```python -client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy_id) +client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy.id) ``` ### Arguments diff --git a/docs/metadata_templates.md b/docs/metadata_templates.md index a1d89743..d00fe83f 100644 --- a/docs/metadata_templates.md +++ b/docs/metadata_templates.md @@ -278,7 +278,36 @@ client.metadata_templates.create_metadata_template( type=CreateMetadataTemplateFieldsTypeField.STRING, key="testName", display_name="testName", - ) + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.FLOAT, + key="age", + display_name="age", + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.DATE, + key="birthDate", + display_name="birthDate", + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.ENUM, + key="countryCode", + display_name="countryCode", + options=[ + CreateMetadataTemplateFieldsOptionsField(key="US"), + CreateMetadataTemplateFieldsOptionsField(key="CA"), + ], + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.MULTISELECT, + key="sports", + display_name="sports", + options=[ + CreateMetadataTemplateFieldsOptionsField(key="basketball"), + CreateMetadataTemplateFieldsOptionsField(key="football"), + CreateMetadataTemplateFieldsOptionsField(key="tennis"), + ], + ), ], ) ``` diff --git a/docs/search.md b/docs/search.md index 28907ea1..64d59692 100644 --- a/docs/search.md +++ b/docs/search.md @@ -75,9 +75,23 @@ See the endpoint docs at ```python client.search.search_for_content( - query=keyword, ancestor_folder_ids=["0"], - trash_content=SearchForContentTrashContent.NON_TRASHED_ONLY, + mdfilters=[ + MetadataFilter( + filters={ + "stringField": "stringValue", + "dateField": MetadataFieldFilterDateRange( + lt=date_time_from_string("2035-01-01T00:00:00Z"), + gt=date_time_from_string("2035-01-03T00:00:00Z"), + ), + "floatField": MetadataFieldFilterFloatRange(lt=9.5, gt=10.5), + "enumField": "enumValue2", + "multiSelectField": ["multiSelectValue1", "multiSelectValue2"], + }, + scope=MetadataFilterScopeField.ENTERPRISE, + template_key=template_key, + ) + ], ) ``` diff --git a/test/legal_hold_policies.py b/test/legal_hold_policies.py index 20aa2302..fff6788d 100644 --- a/test/legal_hold_policies.py +++ b/test/legal_hold_policies.py @@ -1,9 +1,9 @@ +from box_sdk_gen.internal.utils import DateTime + from box_sdk_gen.schemas.legal_hold_policy import LegalHoldPolicy from box_sdk_gen.schemas.legal_hold_policies import LegalHoldPolicies -from box_sdk_gen.internal.utils import DateTime - from box_sdk_gen.internal.utils import get_uuid from box_sdk_gen.internal.utils import date_time_from_string @@ -17,6 +17,31 @@ client: BoxClient = get_default_client() +def testCreateNotOngoingLegalHoldPolicy(): + legal_hold_policy_name: str = get_uuid() + legal_hold_description: str = 'test description' + filter_started_at: DateTime = date_time_from_string('2021-01-01T00:00:00-08:00') + filter_ended_at: DateTime = date_time_from_string('2022-01-01T00:00:00-08:00') + legal_hold_policy: LegalHoldPolicy = ( + client.legal_hold_policies.create_legal_hold_policy( + legal_hold_policy_name, + description=legal_hold_description, + filter_started_at=filter_started_at, + filter_ended_at=filter_ended_at, + is_ongoing=False, + ) + ) + assert legal_hold_policy.policy_name == legal_hold_policy_name + assert legal_hold_policy.description == legal_hold_description + assert date_time_to_string( + legal_hold_policy.filter_started_at + ) == date_time_to_string(filter_started_at) + assert date_time_to_string( + legal_hold_policy.filter_ended_at + ) == date_time_to_string(filter_ended_at) + client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy.id) + + def testCreateUpdateGetDeleteLegalHoldPolicy(): legal_hold_policy_name: str = get_uuid() legal_hold_description: str = 'test description' @@ -44,28 +69,3 @@ def testCreateUpdateGetDeleteLegalHoldPolicy(): ) assert updated_legal_hold_policy.policy_name == updated_legal_hold_policy_name client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy_id) - - -def testCreateNotOngoingLegalHoldPolicy(): - legal_hold_policy_name: str = get_uuid() - legal_hold_description: str = 'test description' - filter_started_at: DateTime = date_time_from_string('2021-01-01T00:00:00-08:00') - filter_ended_at: DateTime = date_time_from_string('2022-01-01T00:00:00-08:00') - legal_hold_policy: LegalHoldPolicy = ( - client.legal_hold_policies.create_legal_hold_policy( - legal_hold_policy_name, - description=legal_hold_description, - filter_started_at=filter_started_at, - filter_ended_at=filter_ended_at, - is_ongoing=False, - ) - ) - assert legal_hold_policy.policy_name == legal_hold_policy_name - assert legal_hold_policy.description == legal_hold_description - assert date_time_to_string( - legal_hold_policy.filter_started_at - ) == date_time_to_string(filter_started_at) - assert date_time_to_string( - legal_hold_policy.filter_ended_at - ) == date_time_to_string(filter_ended_at) - client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy.id) diff --git a/test/metadata_templates.py b/test/metadata_templates.py index 510a70cb..0a3fbb95 100644 --- a/test/metadata_templates.py +++ b/test/metadata_templates.py @@ -1,3 +1,5 @@ +from box_sdk_gen.internal.utils import to_string + import pytest from box_sdk_gen.client import BoxClient @@ -10,6 +12,10 @@ CreateMetadataTemplateFieldsTypeField, ) +from box_sdk_gen.managers.metadata_templates import ( + CreateMetadataTemplateFieldsOptionsField, +) + from box_sdk_gen.managers.metadata_templates import UpdateMetadataTemplateScope from box_sdk_gen.managers.metadata_templates import UpdateMetadataTemplateRequestBody @@ -52,14 +58,56 @@ def testMetadataTemplates(): type=CreateMetadataTemplateFieldsTypeField.STRING, key='testName', display_name='testName', - ) + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.FLOAT, + key='age', + display_name='age', + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.DATE, + key='birthDate', + display_name='birthDate', + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.ENUM, + key='countryCode', + display_name='countryCode', + options=[ + CreateMetadataTemplateFieldsOptionsField(key='US'), + CreateMetadataTemplateFieldsOptionsField(key='CA'), + ], + ), + CreateMetadataTemplateFields( + type=CreateMetadataTemplateFieldsTypeField.MULTISELECT, + key='sports', + display_name='sports', + options=[ + CreateMetadataTemplateFieldsOptionsField(key='basketball'), + CreateMetadataTemplateFieldsOptionsField(key='football'), + CreateMetadataTemplateFieldsOptionsField(key='tennis'), + ], + ), ], ) assert template.template_key == template_key assert template.display_name == template_key - assert len(template.fields) == 1 + assert len(template.fields) == 5 assert template.fields[0].key == 'testName' assert template.fields[0].display_name == 'testName' + assert to_string(template.fields[0].type) == 'string' + assert template.fields[1].key == 'age' + assert template.fields[1].display_name == 'age' + assert to_string(template.fields[1].type) == 'float' + assert template.fields[2].key == 'birthDate' + assert template.fields[2].display_name == 'birthDate' + assert to_string(template.fields[2].type) == 'date' + assert template.fields[3].key == 'countryCode' + assert template.fields[3].display_name == 'countryCode' + assert to_string(template.fields[3].type) == 'enum' + assert template.fields[4].key == 'sports' + assert template.fields[4].display_name == 'sports' + assert to_string(template.fields[4].type) == 'multiSelect' updated_template: MetadataTemplate = ( client.metadata_templates.update_metadata_template( UpdateMetadataTemplateScope.ENTERPRISE, @@ -73,9 +121,9 @@ def testMetadataTemplates(): ], ) ) - assert len(updated_template.fields) == 2 - assert updated_template.fields[1].key == 'newfieldname' - assert updated_template.fields[1].display_name == 'newFieldName' + assert len(updated_template.fields) == 6 + assert updated_template.fields[5].key == 'newfieldname' + assert updated_template.fields[5].display_name == 'newFieldName' get_metadata_template: MetadataTemplate = ( client.metadata_templates.get_metadata_template_by_id(template.id) ) diff --git a/test/search.py b/test/search.py index 0a4570e3..6b6ad7de 100644 --- a/test/search.py +++ b/test/search.py @@ -38,12 +38,12 @@ SearchResultsWithSharedLinks, ) -from box_sdk_gen.managers.search import SearchForContentTrashContent - from box_sdk_gen.schemas.metadata_filter import MetadataFilter from box_sdk_gen.schemas.metadata_filter import MetadataFilterScopeField +from box_sdk_gen.managers.search import SearchForContentTrashContent + from box_sdk_gen.internal.utils import get_uuid from box_sdk_gen.internal.utils import generate_byte_stream @@ -151,29 +151,6 @@ def testCreateMetaDataQueryExecuteRead(): client.files.delete_file_by_id(file.id) -def testGetSearch(): - keyword: str = 'test' - search: Union[SearchResults, SearchResultsWithSharedLinks] = ( - client.search.search_for_content( - query=keyword, - ancestor_folder_ids=['0'], - trash_content=SearchForContentTrashContent.NON_TRASHED_ONLY, - ) - ) - assert len(search.entries) >= 0 - assert to_string(search.type) == 'search_results_items' - search_with_shared_link: Union[SearchResults, SearchResultsWithSharedLinks] = ( - client.search.search_for_content( - query=keyword, - ancestor_folder_ids=['0'], - trash_content=SearchForContentTrashContent.NON_TRASHED_ONLY, - include_recent_shared_links=True, - ) - ) - assert len(search_with_shared_link.entries) >= 0 - assert to_string(search_with_shared_link.type) == 'search_results_with_shared_links' - - def testMetadataFilters(): template_key: str = ''.join(['key', get_uuid()]) template: MetadataTemplate = client.metadata_templates.create_metadata_template( @@ -261,3 +238,26 @@ def testMetadataFilters(): DeleteMetadataTemplateScope.ENTERPRISE, template.template_key ) client.files.delete_file_by_id(file.id) + + +def testGetSearch(): + keyword: str = 'test' + search: Union[SearchResults, SearchResultsWithSharedLinks] = ( + client.search.search_for_content( + query=keyword, + ancestor_folder_ids=['0'], + trash_content=SearchForContentTrashContent.NON_TRASHED_ONLY, + ) + ) + assert len(search.entries) >= 0 + assert to_string(search.type) == 'search_results_items' + search_with_shared_link: Union[SearchResults, SearchResultsWithSharedLinks] = ( + client.search.search_for_content( + query=keyword, + ancestor_folder_ids=['0'], + trash_content=SearchForContentTrashContent.NON_TRASHED_ONLY, + include_recent_shared_links=True, + ) + ) + assert len(search_with_shared_link.entries) >= 0 + assert to_string(search_with_shared_link.type) == 'search_results_with_shared_links' From e5f7815e2b250ed7e54bc79eda252b1cab7027cb Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 26 Feb 2025 00:41:22 -0800 Subject: [PATCH 06/18] 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 3fe1b974..a607eed2 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "ef00939", "specHash": "06fc5f7", "version": "1.12.0" } +{ "engineHash": "77017fa", "specHash": "06fc5f7", "version": "1.12.0" } From 7a74063fe2c5c6cd40efc7c813b098a6d7bc1830 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 26 Feb 2025 02:39:02 -0800 Subject: [PATCH 07/18] 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 a607eed2..ff8da222 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "77017fa", "specHash": "06fc5f7", "version": "1.12.0" } +{ "engineHash": "271bf60", "specHash": "06fc5f7", "version": "1.12.0" } From 764e56f4edf512b7ae200878aa9897e4bd9c8210 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Mon, 3 Mar 2025 06:07:16 -0800 Subject: [PATCH 08/18] 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 ff8da222..01f987f7 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "271bf60", "specHash": "06fc5f7", "version": "1.12.0" } +{ "engineHash": "271bf60", "specHash": "6782a0d", "version": "1.12.0" } From c211acf104367a8b671b4ff66048fb777c5d4baf Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 5 Mar 2025 06:08:46 -0800 Subject: [PATCH 09/18] 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 01f987f7..3f8cc2ce 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "271bf60", "specHash": "6782a0d", "version": "1.12.0" } +{ "engineHash": "91ccaf2", "specHash": "6782a0d", "version": "1.12.0" } From ef5402504f0c34b76b918ce1986729e7239bf94f Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 6 Mar 2025 05:41:34 -0800 Subject: [PATCH 10/18] 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 3f8cc2ce..6cb669f7 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "91ccaf2", "specHash": "6782a0d", "version": "1.12.0" } +{ "engineHash": "ed65d4f", "specHash": "6782a0d", "version": "1.12.0" } From dd91b1d9a82163ace49fbe0cc16670f54acacb31 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Mon, 10 Mar 2025 03:11:32 -0700 Subject: [PATCH 11/18] test: Remove notification_email test because of business logic has changed (box/box-codegen#677) --- .codegen.json | 2 +- test/users.py | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/.codegen.json b/.codegen.json index 6cb669f7..ffa71865 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "ed65d4f", "specHash": "6782a0d", "version": "1.12.0" } +{ "engineHash": "8f5e41b", "specHash": "6782a0d", "version": "1.12.0" } diff --git a/test/users.py b/test/users.py index 6b1cbf39..f200b971 100644 --- a/test/users.py +++ b/test/users.py @@ -6,8 +6,6 @@ from box_sdk_gen.schemas.user_full import UserFull -from box_sdk_gen.managers.users import UpdateUserByIdNotificationEmail - from box_sdk_gen.internal.utils import get_uuid from box_sdk_gen.internal.utils import create_null @@ -42,20 +40,3 @@ def test_create_update_get_delete_user(): ) assert updated_user.name == updated_user_name client.users.delete_user_by_id(user.id) - - -def test_user_notification_email(): - user_name: str = get_uuid() - user_login: str = ''.join([get_uuid(), '@gmail.com']) - user: UserFull = client.users.create_user( - user_name, login=user_login, is_platform_access_only=True - ) - updated_with_notification_email: UserFull = client.users.update_user_by_id( - user.id, notification_email=UpdateUserByIdNotificationEmail(email=user_login) - ) - assert not updated_with_notification_email.notification_email == None - updated_without_notification_email: UserFull = client.users.update_user_by_id( - user.id, notification_email=create_null() - ) - assert updated_without_notification_email.notification_email == None - client.users.delete_user_by_id(user.id) From 6e45783579e01387fbe2af8f71054a81fbe97f42 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Mon, 10 Mar 2025 05:41:06 -0700 Subject: [PATCH 12/18] 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 ffa71865..19a2ed18 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "8f5e41b", "specHash": "6782a0d", "version": "1.12.0" } +{ "engineHash": "2b41544", "specHash": "6782a0d", "version": "1.12.0" } From 1d83fae13e5b898dc2de61807aa4c76633c96663 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Tue, 11 Mar 2025 10:08:51 -0700 Subject: [PATCH 13/18] 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 19a2ed18..0318c942 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2b41544", "specHash": "6782a0d", "version": "1.12.0" } +{ "engineHash": "41feeaa", "specHash": "6782a0d", "version": "1.12.0" } From 2394b1148beb1753f87f706cc7a36bca4a9c2259 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 12 Mar 2025 07:11:21 -0700 Subject: [PATCH 14/18] feat: add find app item for shared link endpoint (box/box-openapi#514) --- .codegen.json | 2 +- box_sdk_gen/client.py | 5 ++ box_sdk_gen/managers/__init__.py | 2 + .../managers/shared_links_app_items.py | 84 +++++++++++++++++++ docs/README.md | 1 + docs/shared_links_app_items.md | 30 +++++++ docs/shared_links_web_links.md | 2 +- 7 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 box_sdk_gen/managers/shared_links_app_items.py create mode 100644 docs/shared_links_app_items.md diff --git a/.codegen.json b/.codegen.json index 0318c942..1aa45385 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "41feeaa", "specHash": "6782a0d", "version": "1.12.0" } +{ "engineHash": "41feeaa", "specHash": "3dc6f70", "version": "1.12.0" } diff --git a/box_sdk_gen/client.py b/box_sdk_gen/client.py index 9499dd80..0ee1e45f 100644 --- a/box_sdk_gen/client.py +++ b/box_sdk_gen/client.py @@ -70,6 +70,8 @@ from box_sdk_gen.managers.shared_links_web_links import SharedLinksWebLinksManager +from box_sdk_gen.managers.shared_links_app_items import SharedLinksAppItemsManager + from box_sdk_gen.managers.users import UsersManager from box_sdk_gen.managers.session_termination import SessionTerminationManager @@ -289,6 +291,9 @@ def __init__(self, auth: Authentication, *, network_session: NetworkSession = No self.shared_links_web_links = SharedLinksWebLinksManager( auth=self.auth, network_session=self.network_session ) + self.shared_links_app_items = SharedLinksAppItemsManager( + auth=self.auth, network_session=self.network_session + ) self.users = UsersManager(auth=self.auth, network_session=self.network_session) self.session_termination = SessionTerminationManager( 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 ea34b02a..b28704d8 100644 --- a/box_sdk_gen/managers/__init__.py +++ b/box_sdk_gen/managers/__init__.py @@ -66,6 +66,8 @@ from box_sdk_gen.managers.shared_links_web_links import * +from box_sdk_gen.managers.shared_links_app_items import * + from box_sdk_gen.managers.users import * from box_sdk_gen.managers.session_termination import * diff --git a/box_sdk_gen/managers/shared_links_app_items.py b/box_sdk_gen/managers/shared_links_app_items.py new file mode 100644 index 00000000..34286162 --- /dev/null +++ b/box_sdk_gen/managers/shared_links_app_items.py @@ -0,0 +1,84 @@ +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 box_sdk_gen.networking.fetch_options import ResponseFormat + +from box_sdk_gen.schemas.app_item import AppItem + +from box_sdk_gen.schemas.client_error import ClientError + +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 SharedLinksAppItemsManager: + 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_shared_item_app_items( + self, boxapi: str, *, extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> AppItem: + """ + Returns the app item represented by a shared link. + + The link can originate from the current enterprise or another. + + :param boxapi: A header containing the shared link and optional password for the + shared link. + + The format for this header is `shared_link=[link]&shared_link_password=[password]` + :type boxapi: str + :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 = {} + headers_map: Dict[str, str] = prepare_params( + {'boxapi': to_string(boxapi), **extra_headers} + ) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/shared_items#app_items', + ] + ), + method='GET', + headers=headers_map, + response_format=ResponseFormat.JSON, + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, AppItem) diff --git a/docs/README.md b/docs/README.md index 8d56a694..73f0f359 100644 --- a/docs/README.md +++ b/docs/README.md @@ -49,6 +49,7 @@ the SDK are available by topic: - [Retention policy assignments](retention_policy_assignments.md) - [Search](search.md) - [Session termination](session_termination.md) +- [Shared links app items](shared_links_app_items.md) - [Shared links files](shared_links_files.md) - [Shared links folders](shared_links_folders.md) - [Shared links web links](shared_links_web_links.md) diff --git a/docs/shared_links_app_items.md b/docs/shared_links_app_items.md new file mode 100644 index 00000000..17630910 --- /dev/null +++ b/docs/shared_links_app_items.md @@ -0,0 +1,30 @@ +# SharedLinksAppItemsManager + +- [Find app item for shared link](#find-app-item-for-shared-link) + +## Find app item for shared link + +Returns the app item represented by a shared link. + +The link can originate from the current enterprise or another. + +This operation is performed by calling function `get_shared_item_app_items`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/get-shared-items--app-items/). + +_Currently we don't have an example for calling `get_shared_item_app_items` in integration tests_ + +### Arguments + +- boxapi `str` + - A header containing the shared link and optional password for the shared link. The format for this header is `shared_link=[link]&shared_link_password=[password]` +- 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 `AppItem`. + +Returns a full app item resource if the shared link is valid and +the user has access to it. diff --git a/docs/shared_links_web_links.md b/docs/shared_links_web_links.md index df7c4124..117b9289 100644 --- a/docs/shared_links_web_links.md +++ b/docs/shared_links_web_links.md @@ -50,7 +50,7 @@ user_client.shared_links_web_links.find_web_link_for_shared_link( This function returns a value of type `WebLink`. -Returns a full file resource if the shared link is valid and +Returns a full web link resource if the shared link is valid and the user has access to it. ## Get shared link for web link From 779811b75a0e7ce88bab4c83eed5d35e81ca365d Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 12 Mar 2025 07:38:51 -0700 Subject: [PATCH 15/18] fix: add verification_phone_number property to create sign request (box/box-openapi#515) --- .codegen.json | 2 +- box_sdk_gen/schemas/sign_request_create_signer.py | 6 ++++++ box_sdk_gen/schemas/sign_request_signer.py | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.codegen.json b/.codegen.json index 1aa45385..8a3dbb4d 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "41feeaa", "specHash": "3dc6f70", "version": "1.12.0" } +{ "engineHash": "41feeaa", "specHash": "1080bb4", "version": "1.12.0" } diff --git a/box_sdk_gen/schemas/sign_request_create_signer.py b/box_sdk_gen/schemas/sign_request_create_signer.py index 8293c86b..7b97859c 100644 --- a/box_sdk_gen/schemas/sign_request_create_signer.py +++ b/box_sdk_gen/schemas/sign_request_create_signer.py @@ -25,6 +25,7 @@ def __init__( redirect_url: Optional[str] = None, declined_redirect_url: Optional[str] = None, login_required: Optional[bool] = None, + verification_phone_number: Optional[str] = None, password: Optional[str] = None, signer_group_id: Optional[str] = None, suppress_notifications: Optional[bool] = None, @@ -64,6 +65,10 @@ def __init__( an existing account, they will have the option to create a free Box account., defaults to None :type login_required: Optional[bool], optional + :param verification_phone_number: If set, this phone number will be used to verify the signer + via two-factor authentication before they are able to sign the document. + Cannot be selected in combination with `login_required`., defaults to None + :type verification_phone_number: Optional[str], optional :param password: If set, the signer is required to enter the password before they are able to sign a document. This field is write only., defaults to None :type password: Optional[str], optional @@ -87,6 +92,7 @@ def __init__( self.redirect_url = redirect_url self.declined_redirect_url = declined_redirect_url self.login_required = login_required + self.verification_phone_number = verification_phone_number self.password = password self.signer_group_id = signer_group_id self.suppress_notifications = suppress_notifications diff --git a/box_sdk_gen/schemas/sign_request_signer.py b/box_sdk_gen/schemas/sign_request_signer.py index 5585738e..25141ffe 100644 --- a/box_sdk_gen/schemas/sign_request_signer.py +++ b/box_sdk_gen/schemas/sign_request_signer.py @@ -66,6 +66,7 @@ def __init__( redirect_url: Optional[str] = None, declined_redirect_url: Optional[str] = None, login_required: Optional[bool] = None, + verification_phone_number: Optional[str] = None, password: Optional[str] = None, signer_group_id: Optional[str] = None, suppress_notifications: Optional[bool] = None, @@ -118,6 +119,10 @@ def __init__( an existing account, they will have the option to create a free Box account., defaults to None :type login_required: Optional[bool], optional + :param verification_phone_number: If set, this phone number will be used to verify the signer + via two-factor authentication before they are able to sign the document. + Cannot be selected in combination with `login_required`., defaults to None + :type verification_phone_number: Optional[str], optional :param password: If set, the signer is required to enter the password before they are able to sign a document. This field is write only., defaults to None :type password: Optional[str], optional @@ -141,6 +146,7 @@ def __init__( redirect_url=redirect_url, declined_redirect_url=declined_redirect_url, login_required=login_required, + verification_phone_number=verification_phone_number, password=password, signer_group_id=signer_group_id, suppress_notifications=suppress_notifications, From adfa47cb36cd85f91a8de210ab5bb9297e1c1b7d Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 12 Mar 2025 07:40:41 -0700 Subject: [PATCH 16/18] 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 8a3dbb4d..ff85c119 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "41feeaa", "specHash": "1080bb4", "version": "1.12.0" } +{ "engineHash": "41feeaa", "specHash": "314e2b1", "version": "1.12.0" } From cbd58199634312d02ba3d9371ab97e67d5e74932 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 12 Mar 2025 07:42:30 -0700 Subject: [PATCH 17/18] feat: add Integration Mappings Teams API (box/box-openapi#517) --- .codegen.json | 2 +- box_sdk_gen/managers/integration_mappings.py | 213 ++++++++++++++++++ box_sdk_gen/schemas/__init__.py | 12 + box_sdk_gen/schemas/folder_reference.py | 30 +++ .../integration_mapping_partner_item_teams.py | 34 +++ ...pping_partner_item_teams_create_request.py | 38 ++++ .../schemas/integration_mapping_teams.py | 69 ++++++ ...ntegration_mapping_teams_create_request.py | 21 ++ .../schemas/integration_mappings_teams.py | 21 ++ docs/integration_mappings.md | 120 ++++++++++ 10 files changed, 559 insertions(+), 1 deletion(-) create mode 100644 box_sdk_gen/schemas/folder_reference.py create mode 100644 box_sdk_gen/schemas/integration_mapping_partner_item_teams.py create mode 100644 box_sdk_gen/schemas/integration_mapping_partner_item_teams_create_request.py create mode 100644 box_sdk_gen/schemas/integration_mapping_teams.py create mode 100644 box_sdk_gen/schemas/integration_mapping_teams_create_request.py create mode 100644 box_sdk_gen/schemas/integration_mappings_teams.py diff --git a/.codegen.json b/.codegen.json index ff85c119..0bd96dae 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "41feeaa", "specHash": "314e2b1", "version": "1.12.0" } +{ "engineHash": "41feeaa", "specHash": "c303afc", "version": "1.12.0" } diff --git a/box_sdk_gen/managers/integration_mappings.py b/box_sdk_gen/managers/integration_mappings.py index 8dac7e0a..b3069eb0 100644 --- a/box_sdk_gen/managers/integration_mappings.py +++ b/box_sdk_gen/managers/integration_mappings.py @@ -16,6 +16,10 @@ IntegrationMappingPartnerItemSlack, ) +from box_sdk_gen.schemas.integration_mapping_partner_item_teams_create_request import ( + IntegrationMappingPartnerItemTeamsCreateRequest, +) + from box_sdk_gen.schemas.integration_mappings import IntegrationMappings from box_sdk_gen.schemas.client_error import ClientError @@ -34,6 +38,16 @@ IntegrationMappingSlackOptions, ) +from box_sdk_gen.schemas.integration_mappings_teams import IntegrationMappingsTeams + +from box_sdk_gen.schemas.integration_mapping_teams import IntegrationMappingTeams + +from box_sdk_gen.schemas.integration_mapping_teams_create_request import ( + IntegrationMappingTeamsCreateRequest, +) + +from box_sdk_gen.schemas.folder_reference import FolderReference + from box_sdk_gen.box.errors import BoxSDKError from box_sdk_gen.networking.auth import Authentication @@ -63,6 +77,15 @@ class GetSlackIntegrationMappingBoxItemType(str, Enum): FOLDER = 'folder' +class GetIntegrationMappingTeamsPartnerItemType(str, Enum): + CHANNEL = 'channel' + TEAM = 'team' + + +class GetIntegrationMappingTeamsBoxItemType(str, Enum): + FOLDER = 'folder' + + class IntegrationMappingsManager: def __init__( self, @@ -285,3 +308,193 @@ def delete_slack_integration_mapping_by_id( ) ) return None + + def get_integration_mapping_teams( + self, + *, + partner_item_type: Optional[GetIntegrationMappingTeamsPartnerItemType] = None, + partner_item_id: Optional[str] = None, + box_item_id: Optional[str] = None, + box_item_type: Optional[GetIntegrationMappingTeamsBoxItemType] = None, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> IntegrationMappingsTeams: + """ + Lists [Teams integration mappings](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) in a users' enterprise. + + You need Admin or Co-Admin role to + + + use this endpoint. + + :param partner_item_type: Mapped item type, for which the mapping should be returned, defaults to None + :type partner_item_type: Optional[GetIntegrationMappingTeamsPartnerItemType], optional + :param partner_item_id: ID of the mapped item, for which the mapping should be returned, defaults to None + :type partner_item_id: Optional[str], optional + :param box_item_id: Box item ID, for which the mappings should be returned, defaults to None + :type box_item_id: Optional[str], optional + :param box_item_type: Box item type, for which the mappings should be returned, defaults to None + :type box_item_type: Optional[GetIntegrationMappingTeamsBoxItemType], 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( + { + 'partner_item_type': to_string(partner_item_type), + 'partner_item_id': to_string(partner_item_id), + 'box_item_id': to_string(box_item_id), + 'box_item_type': to_string(box_item_type), + } + ) + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/integration_mappings/teams', + ] + ), + 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, IntegrationMappingsTeams) + + def create_integration_mapping_teams( + self, + partner_item: IntegrationMappingPartnerItemTeamsCreateRequest, + box_item: FolderReference, + *, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> IntegrationMappingTeams: + """ + Creates a [Teams integration mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) + + by mapping a Teams channel to a Box item. + + + You need Admin or Co-Admin role to + + + use this endpoint. + + :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 = {'partner_item': partner_item, 'box_item': box_item} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/integration_mappings/teams', + ] + ), + 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, IntegrationMappingTeams) + + def update_integration_mapping_teams_by_id( + self, + integration_mapping_id: str, + *, + box_item: Optional[FolderReference] = None, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> IntegrationMappingTeams: + """ + Updates a [Teams integration mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). + + Supports updating the Box folder ID and options. + + + You need Admin or Co-Admin role to + + + use this endpoint. + + :param integration_mapping_id: An ID of an integration mapping + Example: "11235432" + :type integration_mapping_id: str + :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 = {'box_item': box_item} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/integration_mappings/teams/', + to_string(integration_mapping_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, IntegrationMappingTeams) + + def delete_integration_mapping_teams_by_id( + self, + integration_mapping_id: str, + *, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> None: + """ + Deletes a [Teams integration mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). + + You need Admin or Co-Admin role to + + + use this endpoint. + + :param integration_mapping_id: An ID of an integration mapping + Example: "11235432" + :type integration_mapping_id: str + :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 = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = self.network_session.network_client.fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/integration_mappings/teams/', + to_string(integration_mapping_id), + ] + ), + method='DELETE', + headers=headers_map, + response_format=ResponseFormat.NO_CONTENT, + auth=self.auth, + network_session=self.network_session, + ) + ) + return None diff --git a/box_sdk_gen/schemas/__init__.py b/box_sdk_gen/schemas/__init__.py index e5b273c2..5c45dbe5 100644 --- a/box_sdk_gen/schemas/__init__.py +++ b/box_sdk_gen/schemas/__init__.py @@ -120,6 +120,8 @@ from box_sdk_gen.schemas.access_token import * +from box_sdk_gen.schemas.folder_reference import * + from box_sdk_gen.schemas.generic_source import * from box_sdk_gen.schemas.group_base import * @@ -138,6 +140,16 @@ from box_sdk_gen.schemas.integration_mapping_partner_item_slack import * +from box_sdk_gen.schemas.integration_mapping_partner_item_teams import * + +from box_sdk_gen.schemas.integration_mapping_teams import * + +from box_sdk_gen.schemas.integration_mappings_teams import * + +from box_sdk_gen.schemas.integration_mapping_partner_item_teams_create_request import * + +from box_sdk_gen.schemas.integration_mapping_teams_create_request import * + from box_sdk_gen.schemas.integration_mapping_slack_options import * from box_sdk_gen.schemas.integration_mapping_slack_create_request import * diff --git a/box_sdk_gen/schemas/folder_reference.py b/box_sdk_gen/schemas/folder_reference.py new file mode 100644 index 00000000..b5389f66 --- /dev/null +++ b/box_sdk_gen/schemas/folder_reference.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 FolderReferenceTypeField(str, Enum): + FOLDER = 'folder' + + +class FolderReference(BaseObject): + _discriminator = 'type', {'folder'} + + def __init__( + self, + id: str, + *, + type: FolderReferenceTypeField = FolderReferenceTypeField.FOLDER, + **kwargs + ): + """ + :param id: ID of the folder + :type id: str + :param type: `folder`, defaults to FolderReferenceTypeField.FOLDER + :type type: FolderReferenceTypeField, optional + """ + super().__init__(**kwargs) + self.id = id + self.type = type diff --git a/box_sdk_gen/schemas/integration_mapping_partner_item_teams.py b/box_sdk_gen/schemas/integration_mapping_partner_item_teams.py new file mode 100644 index 00000000..7e7a31c5 --- /dev/null +++ b/box_sdk_gen/schemas/integration_mapping_partner_item_teams.py @@ -0,0 +1,34 @@ +from enum import Enum + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class IntegrationMappingPartnerItemTeamsTypeField(str, Enum): + CHANNEL = 'channel' + TEAM = 'team' + + +class IntegrationMappingPartnerItemTeams(BaseObject): + _discriminator = 'type', {'channel', 'team'} + + def __init__( + self, + type: IntegrationMappingPartnerItemTeamsTypeField, + id: str, + tenant_id: str, + **kwargs + ): + """ + :param type: Type of the mapped item referenced in `id` + :type type: IntegrationMappingPartnerItemTeamsTypeField + :param id: ID of the mapped item (of type referenced in `type`) + :type id: str + :param tenant_id: ID of the tenant that is registered with Microsoft Teams. + :type tenant_id: str + """ + super().__init__(**kwargs) + self.type = type + self.id = id + self.tenant_id = tenant_id diff --git a/box_sdk_gen/schemas/integration_mapping_partner_item_teams_create_request.py b/box_sdk_gen/schemas/integration_mapping_partner_item_teams_create_request.py new file mode 100644 index 00000000..606160f0 --- /dev/null +++ b/box_sdk_gen/schemas/integration_mapping_partner_item_teams_create_request.py @@ -0,0 +1,38 @@ +from enum import Enum + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.box.errors import BoxSDKError + + +class IntegrationMappingPartnerItemTeamsCreateRequestTypeField(str, Enum): + CHANNEL = 'channel' + TEAM = 'team' + + +class IntegrationMappingPartnerItemTeamsCreateRequest(BaseObject): + _discriminator = 'type', {'channel', 'team'} + + def __init__( + self, + type: IntegrationMappingPartnerItemTeamsCreateRequestTypeField, + id: str, + tenant_id: str, + team_id: str, + **kwargs + ): + """ + :param type: Type of the mapped item referenced in `id` + :type type: IntegrationMappingPartnerItemTeamsCreateRequestTypeField + :param id: ID of the mapped item (of type referenced in `type`) + :type id: str + :param tenant_id: ID of the tenant that is registered with Microsoft Teams. + :type tenant_id: str + :param team_id: ID of the team that is registered with Microsoft Teams. + :type team_id: str + """ + super().__init__(**kwargs) + self.type = type + self.id = id + self.tenant_id = tenant_id + self.team_id = team_id diff --git a/box_sdk_gen/schemas/integration_mapping_teams.py b/box_sdk_gen/schemas/integration_mapping_teams.py new file mode 100644 index 00000000..b82ea9ee --- /dev/null +++ b/box_sdk_gen/schemas/integration_mapping_teams.py @@ -0,0 +1,69 @@ +from enum import Enum + +from typing import Optional + +from typing import Union + +from box_sdk_gen.schemas.integration_mapping_base import IntegrationMappingBaseTypeField + +from box_sdk_gen.schemas.integration_mapping_base import IntegrationMappingBase + +from box_sdk_gen.schemas.integration_mapping_partner_item_teams import ( + IntegrationMappingPartnerItemTeams, +) + +from box_sdk_gen.schemas.folder_reference import FolderReference + +from box_sdk_gen.box.errors import BoxSDKError + +from box_sdk_gen.internal.utils import DateTime + + +class IntegrationMappingTeamsIntegrationTypeField(str, Enum): + TEAMS = 'teams' + + +class IntegrationMappingTeams(IntegrationMappingBase): + def __init__( + self, + partner_item: Union[IntegrationMappingPartnerItemTeams], + box_item: FolderReference, + id: str, + *, + integration_type: Optional[IntegrationMappingTeamsIntegrationTypeField] = None, + is_overridden_by_manual_mapping: Optional[bool] = None, + created_at: Optional[DateTime] = None, + modified_at: Optional[DateTime] = None, + type: IntegrationMappingBaseTypeField = IntegrationMappingBaseTypeField.INTEGRATION_MAPPING, + **kwargs + ): + """ + :param partner_item: Mapped item object for Teams + :type partner_item: Union[IntegrationMappingPartnerItemTeams] + :param id: A unique identifier of a folder mapping + (part of a composite key together + with `integration_type`) + :type id: str + :param integration_type: Identifies the Box partner app, + with which the mapping is associated. + Supports Slack and Teams. + (part of the composite key together with `id`), defaults to None + :type integration_type: Optional[IntegrationMappingTeamsIntegrationTypeField], optional + :param is_overridden_by_manual_mapping: Identifies whether the mapping has + been manually set by the team owner from UI for channels + (as opposed to being automatically created), defaults to None + :type is_overridden_by_manual_mapping: Optional[bool], optional + :param created_at: When the integration mapping object was created, defaults to None + :type created_at: Optional[DateTime], optional + :param modified_at: When the integration mapping object was last modified, defaults to None + :type modified_at: Optional[DateTime], optional + :param type: Mapping type, defaults to IntegrationMappingBaseTypeField.INTEGRATION_MAPPING + :type type: IntegrationMappingBaseTypeField, optional + """ + super().__init__(id=id, type=type, **kwargs) + self.partner_item = partner_item + self.box_item = box_item + self.integration_type = integration_type + self.is_overridden_by_manual_mapping = is_overridden_by_manual_mapping + self.created_at = created_at + self.modified_at = modified_at diff --git a/box_sdk_gen/schemas/integration_mapping_teams_create_request.py b/box_sdk_gen/schemas/integration_mapping_teams_create_request.py new file mode 100644 index 00000000..2f615a43 --- /dev/null +++ b/box_sdk_gen/schemas/integration_mapping_teams_create_request.py @@ -0,0 +1,21 @@ +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.integration_mapping_partner_item_teams_create_request import ( + IntegrationMappingPartnerItemTeamsCreateRequest, +) + +from box_sdk_gen.schemas.folder_reference import FolderReference + +from box_sdk_gen.box.errors import BoxSDKError + + +class IntegrationMappingTeamsCreateRequest(BaseObject): + def __init__( + self, + partner_item: IntegrationMappingPartnerItemTeamsCreateRequest, + box_item: FolderReference, + **kwargs + ): + super().__init__(**kwargs) + self.partner_item = partner_item + self.box_item = box_item diff --git a/box_sdk_gen/schemas/integration_mappings_teams.py b/box_sdk_gen/schemas/integration_mappings_teams.py new file mode 100644 index 00000000..6f35f25b --- /dev/null +++ b/box_sdk_gen/schemas/integration_mappings_teams.py @@ -0,0 +1,21 @@ +from typing import Optional + +from typing import List + +from box_sdk_gen.internal.base_object import BaseObject + +from box_sdk_gen.schemas.integration_mapping_teams import IntegrationMappingTeams + +from box_sdk_gen.box.errors import BoxSDKError + + +class IntegrationMappingsTeams(BaseObject): + def __init__( + self, *, entries: Optional[List[IntegrationMappingTeams]] = None, **kwargs + ): + """ + :param entries: A list of integration mappings, defaults to None + :type entries: Optional[List[IntegrationMappingTeams]], optional + """ + super().__init__(**kwargs) + self.entries = entries diff --git a/docs/integration_mappings.md b/docs/integration_mappings.md index 88329cb1..dcebf90a 100644 --- a/docs/integration_mappings.md +++ b/docs/integration_mappings.md @@ -4,6 +4,10 @@ - [Create Slack integration mapping](#create-slack-integration-mapping) - [Update Slack integration mapping](#update-slack-integration-mapping) - [Delete Slack integration mapping](#delete-slack-integration-mapping) +- [List Teams integration mappings](#list-teams-integration-mappings) +- [Create Teams integration mapping](#create-teams-integration-mapping) +- [Update Teams integration mapping](#update-teams-integration-mapping) +- [Delete Teams integration mapping](#delete-teams-integration-mapping) ## List Slack integration mappings @@ -145,3 +149,119 @@ _Currently we don't have an example for calling `delete_slack_integration_mappin This function returns a value of type `None`. Empty body in response + +## List Teams integration mappings + +Lists [Teams integration mappings](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) in a users' enterprise. +You need Admin or Co-Admin role to +use this endpoint. + +This operation is performed by calling function `get_integration_mapping_teams`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/get-integration-mappings-teams/). + +_Currently we don't have an example for calling `get_integration_mapping_teams` in integration tests_ + +### Arguments + +- partner_item_type `Optional[GetIntegrationMappingTeamsPartnerItemType]` + - Mapped item type, for which the mapping should be returned +- partner_item_id `Optional[str]` + - ID of the mapped item, for which the mapping should be returned +- box_item_id `Optional[str]` + - Box item ID, for which the mappings should be returned +- box_item_type `Optional[GetIntegrationMappingTeamsBoxItemType]` + - Box item type, for which the mappings should be returned +- 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 `IntegrationMappingsTeams`. + +Returns a collection of integration mappings + +## Create Teams integration mapping + +Creates a [Teams integration mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams) +by mapping a Teams channel to a Box item. +You need Admin or Co-Admin role to +use this endpoint. + +This operation is performed by calling function `create_integration_mapping_teams`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/post-integration-mappings-teams/). + +_Currently we don't have an example for calling `create_integration_mapping_teams` in integration tests_ + +### Arguments + +- partner_item `IntegrationMappingPartnerItemTeamsCreateRequest` + - +- box_item `FolderReference` + - +- 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 `IntegrationMappingTeams`. + +Returns the created integration mapping. + +## Update Teams integration mapping + +Updates a [Teams integration mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). +Supports updating the Box folder ID and options. +You need Admin or Co-Admin role to +use this endpoint. + +This operation is performed by calling function `update_integration_mapping_teams_by_id`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-integration-mappings-teams-id/). + +_Currently we don't have an example for calling `update_integration_mapping_teams_by_id` in integration tests_ + +### Arguments + +- integration_mapping_id `str` + - An ID of an integration mapping Example: "11235432" +- box_item `Optional[FolderReference]` + - +- 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 `IntegrationMappingTeams`. + +Returns the updated integration mapping object. + +## Delete Teams integration mapping + +Deletes a [Teams integration mapping](https://support.box.com/hc/en-us/articles/360044681474-Using-Box-for-Teams). +You need Admin or Co-Admin role to +use this endpoint. + +This operation is performed by calling function `delete_integration_mapping_teams_by_id`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/delete-integration-mappings-teams-id/). + +_Currently we don't have an example for calling `delete_integration_mapping_teams_by_id` in integration tests_ + +### Arguments + +- integration_mapping_id `str` + - An ID of an integration mapping Example: "11235432" +- 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 `None`. + +Empty body in response From e2c92f5d12a3eff02043676139201b7f8520a6bb Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 12 Mar 2025 11:41:19 -0700 Subject: [PATCH 18/18] test: Support ITests for Shared Link for App Items (box/box-codegen#673) --- .codegen.json | 2 +- .../managers/shared_links_app_items.py | 2 +- docs/shared_links_app_items.md | 10 ++++++++-- test/shared_links_app_items.py | 20 +++++++++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 test/shared_links_app_items.py diff --git a/.codegen.json b/.codegen.json index 0bd96dae..8130d39f 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "41feeaa", "specHash": "c303afc", "version": "1.12.0" } +{ "engineHash": "be67a6e", "specHash": "c303afc", "version": "1.12.0" } diff --git a/box_sdk_gen/managers/shared_links_app_items.py b/box_sdk_gen/managers/shared_links_app_items.py index 34286162..9c57a897 100644 --- a/box_sdk_gen/managers/shared_links_app_items.py +++ b/box_sdk_gen/managers/shared_links_app_items.py @@ -45,7 +45,7 @@ def __init__( self.auth = auth self.network_session = network_session - def get_shared_item_app_items( + def find_app_item_for_shared_link( self, boxapi: str, *, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> AppItem: """ diff --git a/docs/shared_links_app_items.md b/docs/shared_links_app_items.md index 17630910..a26cdabc 100644 --- a/docs/shared_links_app_items.md +++ b/docs/shared_links_app_items.md @@ -8,12 +8,18 @@ Returns the app item represented by a shared link. The link can originate from the current enterprise or another. -This operation is performed by calling function `get_shared_item_app_items`. +This operation is performed by calling function `find_app_item_for_shared_link`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-shared-items--app-items/). -_Currently we don't have an example for calling `get_shared_item_app_items` in integration tests_ + + +```python +client.shared_links_app_items.find_app_item_for_shared_link( + "".join(["shared_link=", app_item_shared_link]) +) +``` ### Arguments diff --git a/test/shared_links_app_items.py b/test/shared_links_app_items.py new file mode 100644 index 00000000..9b37e30e --- /dev/null +++ b/test/shared_links_app_items.py @@ -0,0 +1,20 @@ +from box_sdk_gen.internal.utils import to_string + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas.app_item import AppItem + +from box_sdk_gen.internal.utils import get_env_var + +from test.commons import get_default_client + +client: BoxClient = get_default_client() + + +def testSharedLinksFiles(): + app_item_shared_link: str = get_env_var('APP_ITEM_SHARED_LINK') + app_item: AppItem = client.shared_links_app_items.find_app_item_for_shared_link( + ''.join(['shared_link=', app_item_shared_link]) + ) + assert to_string(app_item.type) == 'app_item' + assert app_item.application_type == 'hubs'