diff --git a/.codegen.json b/.codegen.json index 26e42a3a..807bffa4 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "4a6ba02", "specHash": "9d452cf", "version": "1.6.0" } +{ "engineHash": "9c64675", "specHash": "c2c76f3", "version": "1.6.0" } diff --git a/box_sdk_gen/managers/collections.py b/box_sdk_gen/managers/collections.py index fb3f49ee..e6481c2a 100644 --- a/box_sdk_gen/managers/collections.py +++ b/box_sdk_gen/managers/collections.py @@ -14,6 +14,8 @@ from box_sdk_gen.schemas.items import Items +from box_sdk_gen.schemas.collection import Collection + from box_sdk_gen.networking.auth import Authentication from box_sdk_gen.networking.network import NetworkSession @@ -176,3 +178,38 @@ def get_collection_items( ) ) return deserialize(response.data, Items) + + def get_collection_by_id( + self, + collection_id: str, + *, + extra_headers: Optional[Dict[str, Optional[str]]] = None + ) -> Collection: + """ + Retrieves a collection by its ID. + :param collection_id: The ID of the collection. + Example: "926489" + :type collection_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 = fetch( + FetchOptions( + url=''.join( + [ + self.network_session.base_urls.base_url, + '/2.0/collections/', + to_string(collection_id), + ] + ), + method='GET', + headers=headers_map, + response_format='json', + auth=self.auth, + network_session=self.network_session, + ) + ) + return deserialize(response.data, Collection) diff --git a/docs/collections.md b/docs/collections.md index cd7d4331..fd95395b 100644 --- a/docs/collections.md +++ b/docs/collections.md @@ -2,6 +2,7 @@ - [List all collections](#list-all-collections) - [List collection items](#list-collection-items) +- [Get collection by ID](#get-collection-by-id) ## List all collections @@ -72,3 +73,27 @@ client.collections.get_collection_items(favourite_collection.id) This function returns a value of type `Items`. Returns an array of items in the collection. + +## Get collection by ID + +Retrieves a collection by its ID. + +This operation is performed by calling function `get_collection_by_id`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/get-collections-id/). + +_Currently we don't have an example for calling `get_collection_by_id` in integration tests_ + +### Arguments + +- collection_id `str` + - The ID of the collection. Example: "926489" +- 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 `Collection`. + +Returns an array of items in the collection.