From dc353088fff732cb0426600389f96c54f81a0fb3 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 14 Sep 2023 05:10:51 -0700 Subject: [PATCH 1/2] generated with codegen at box/box-codegen@03cab03 and spec at box/box-openapi@bc0fe41 --- box_sdk_gen/schemas.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/box_sdk_gen/schemas.py b/box_sdk_gen/schemas.py index 79c421f..8aa81e2 100644 --- a/box_sdk_gen/schemas.py +++ b/box_sdk_gen/schemas.py @@ -7950,14 +7950,16 @@ class SearchResultsWithSharedLinksTypeField(str, Enum): class SearchResultsWithSharedLinks(BaseObject): def __init__( self, + type: SearchResultsWithSharedLinksTypeField, total_count: Optional[int] = None, limit: Optional[int] = None, offset: Optional[int] = None, - type: Optional[SearchResultsWithSharedLinksTypeField] = None, entries: Optional[List[SearchResultWithSharedLink]] = None, **kwargs ): """ + :param type: Specifies the response as search result items with shared links + :type type: SearchResultsWithSharedLinksTypeField :param total_count: One greater than the offset of the last entry in the search results. The total number of entries in the collection may be less than `total_count`. @@ -7969,18 +7971,16 @@ def __init__( :param offset: The 0-based offset of the first entry in this set. This will be the same as the `offset` query parameter used. :type offset: Optional[int], optional - :param type: Specifies the response as search result items with shared links - :type type: Optional[SearchResultsWithSharedLinksTypeField], optional :param entries: The search results for the query provided, including the additional information about any shared links through which the item has been shared with the user. :type entries: Optional[List[SearchResultWithSharedLink]], optional """ super().__init__(**kwargs) + self.type = type self.total_count = total_count self.limit = limit self.offset = offset - self.type = type self.entries = entries @@ -7991,14 +7991,16 @@ class SearchResultsTypeField(str, Enum): class SearchResults(BaseObject): def __init__( self, + type: SearchResultsTypeField, total_count: Optional[int] = None, limit: Optional[int] = None, offset: Optional[int] = None, - type: Optional[SearchResultsTypeField] = None, entries: Optional[List[Union[File, Folder, WebLink]]] = None, **kwargs ): """ + :param type: Specifies the response as search result items without shared links + :type type: SearchResultsTypeField :param total_count: One greater than the offset of the last entry in the search results. The total number of entries in the collection may be less than `total_count`. @@ -8010,16 +8012,14 @@ def __init__( :param offset: The 0-based offset of the first entry in this set. This will be the same as the `offset` query parameter used. :type offset: Optional[int], optional - :param type: Specifies the response as search result items without shared links - :type type: Optional[SearchResultsTypeField], optional :param entries: The search results for the query provided. :type entries: Optional[List[Union[File, Folder, WebLink]]], optional """ super().__init__(**kwargs) + self.type = type self.total_count = total_count self.limit = limit self.offset = offset - self.type = type self.entries = entries From 24f04dfa4b3bdc5a257c719244af93b15b63a614 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 15 Sep 2023 07:48:38 -0700 Subject: [PATCH 2/2] generated with codegen at box/box-codegen@4838692 and spec at box/box-openapi@122fbc3 --- README.md | 14 +-- box_sdk_gen/ccg_auth.py | 2 +- box_sdk_gen/client.py | 2 +- box_sdk_gen/developer_token_auth.py | 2 +- box_sdk_gen/fetch.py | 44 ++++--- box_sdk_gen/jwt_auth.py | 2 +- box_sdk_gen/managers/avatars.py | 4 +- box_sdk_gen/managers/chunked_uploads.py | 22 ++-- box_sdk_gen/managers/classifications.py | 22 ++-- .../collaboration_allowlist_entries.py | 12 +- .../collaboration_allowlist_exempt_targets.py | 12 +- box_sdk_gen/managers/collections.py | 6 +- box_sdk_gen/managers/comments.py | 16 +-- box_sdk_gen/managers/device_pinners.py | 6 +- box_sdk_gen/managers/email_aliases.py | 10 +- box_sdk_gen/managers/events.py | 6 +- box_sdk_gen/managers/file_classifications.py | 14 ++- box_sdk_gen/managers/file_metadata.py | 26 ++-- box_sdk_gen/managers/file_requests.py | 14 ++- .../managers/file_version_legal_holds.py | 6 +- .../managers/file_version_retentions.py | 6 +- box_sdk_gen/managers/file_versions.py | 16 +-- box_sdk_gen/managers/file_watermarks.py | 10 +- box_sdk_gen/managers/files.py | 14 ++- .../managers/folder_classifications.py | 14 ++- box_sdk_gen/managers/folder_locks.py | 10 +- box_sdk_gen/managers/folder_metadata.py | 26 ++-- box_sdk_gen/managers/folder_watermarks.py | 10 +- box_sdk_gen/managers/folders.py | 20 ++-- box_sdk_gen/managers/groups.py | 16 +-- box_sdk_gen/managers/integration_mappings.py | 14 ++- box_sdk_gen/managers/invites.py | 10 +- box_sdk_gen/managers/legal_hold_policies.py | 16 +-- .../managers/legal_hold_policy_assignments.py | 16 +-- box_sdk_gen/managers/list_collaborations.py | 10 +- box_sdk_gen/managers/memberships.py | 18 +-- .../managers/metadata_cascade_policies.py | 14 ++- box_sdk_gen/managers/metadata_templates.py | 22 ++-- box_sdk_gen/managers/recent_items.py | 4 +- box_sdk_gen/managers/retention_policies.py | 16 +-- .../managers/retention_policy_assignments.py | 16 +-- box_sdk_gen/managers/search.py | 10 +- box_sdk_gen/managers/session_termination.py | 12 +- box_sdk_gen/managers/shared_links_files.py | 20 ++-- box_sdk_gen/managers/shared_links_folders.py | 20 ++-- .../managers/shared_links_web_links.py | 20 ++-- .../shield_information_barrier_reports.py | 10 +- ...eld_information_barrier_segment_members.py | 14 +-- ...nformation_barrier_segment_restrictions.py | 14 +-- .../shield_information_barrier_segments.py | 14 ++- .../managers/shield_information_barriers.py | 14 ++- box_sdk_gen/managers/sign_requests.py | 14 ++- box_sdk_gen/managers/sign_templates.py | 6 +- box_sdk_gen/managers/skills.py | 16 +-- box_sdk_gen/managers/storage_policies.py | 6 +- .../managers/storage_policy_assignments.py | 16 +-- box_sdk_gen/managers/task_assignments.py | 16 +-- box_sdk_gen/managers/tasks.py | 16 +-- .../terms_of_service_user_statuses.py | 14 ++- box_sdk_gen/managers/terms_of_services.py | 16 +-- box_sdk_gen/managers/transfer.py | 8 +- box_sdk_gen/managers/trashed_files.py | 10 +- box_sdk_gen/managers/trashed_folders.py | 10 +- box_sdk_gen/managers/trashed_items.py | 4 +- box_sdk_gen/managers/trashed_web_links.py | 10 +- box_sdk_gen/managers/uploads.py | 18 +-- box_sdk_gen/managers/user_collaborations.py | 14 ++- box_sdk_gen/managers/users.py | 18 +-- box_sdk_gen/managers/web_links.py | 14 ++- box_sdk_gen/managers/webhooks.py | 16 +-- box_sdk_gen/managers/workflows.py | 8 +- box_sdk_gen/managers/zip_downloads.py | 10 +- box_sdk_gen/oauth.py | 2 +- box_sdk_gen/schemas.py | 35 +----- box_sdk_gen/serialization.py | 19 +++ docs/authentication.md | 112 +++++++++--------- docs/configuration.md | 8 +- docs/file_metadata.md | 32 ++++- docs/folder_metadata.md | 32 ++++- docs/memberships.md | 2 +- migration-guide.md | 51 ++++---- test/auth.py | 26 ++-- test/avatars.py | 8 +- test/chunked_uploads.py | 8 +- test/collaboration_allowlist_entries.py | 8 +- .../collaboration_allowlist_exempt_targets.py | 8 +- test/collections.py | 8 +- test/comments.py | 8 +- test/commons.py | 8 +- test/downloads.py | 8 +- test/email_aliases.py | 8 +- test/file_metadata.py | 94 +++++++++++++++ test/file_versions.py | 8 +- test/files.py | 31 +++-- test/folder_locks.py | 8 +- test/folder_metadata.py | 90 ++++++++++++++ test/folders.py | 8 +- test/groups.py | 8 +- test/memberships.py | 22 ++-- test/metadata_templates.py | 22 ++-- test/recent_items.py | 8 +- test/retention_policies.py | 8 +- test/sign_requests.py | 8 +- test/tasks.py | 8 +- test/trashed_files.py | 8 +- test/trashed_folders.py | 8 +- test/uploads.py | 8 +- test/users.py | 8 +- test/webhooks.py | 8 +- test/weblinks.py | 8 +- 110 files changed, 1024 insertions(+), 686 deletions(-) create mode 100644 box_sdk_gen/serialization.py create mode 100644 test/file_metadata.py create mode 100644 test/folder_metadata.py diff --git a/README.md b/README.md index 40f5fb0..29a5340 100644 --- a/README.md +++ b/README.md @@ -53,20 +53,20 @@ pip install box-sdk-gen[jwt] To get started with the SDK, get a Developer Token from the Configuration page of your app in the [Box Developer Console](https://app.box.com/developers/console). You can use this token to make test calls for your own Box account. -The SDK provides an `DeveloperTokenAuth` class, which allows you to authenticate using your Developer Token. -Use instance of `DeveloperTokenAuth` to initialize `Client` object. -Using `Client` object you can access managers, which allow you to perform some operations on your Box account. +The SDK provides an `BoxDeveloperTokenAuth` class, which allows you to authenticate using your Developer Token. +Use instance of `BoxDeveloperTokenAuth` to initialize `BoxClient` object. +Using `BoxClient` object you can access managers, which allow you to perform some operations on your Box account. The example below demonstrates how to authenticate with Developer Token and print names of all items inside a root folder. ```python -from box_sdk_gen.developer_token_auth import DeveloperTokenAuth -from box_sdk_gen.client import Client +from box_sdk_gen.developer_token_auth import BoxDeveloperTokenAuth +from box_sdk_gen.client import BoxClient def main(token: str): - auth: DeveloperTokenAuth = DeveloperTokenAuth(token=token) - client: Client = Client(auth=auth) + auth: BoxDeveloperTokenAuth = BoxDeveloperTokenAuth(token=token) + client: BoxClient = BoxClient(auth=auth) for item in client.folders.get_folder_items('0').entries: print(item.name) diff --git a/box_sdk_gen/ccg_auth.py b/box_sdk_gen/ccg_auth.py index 7f7d56f..7f01d1f 100644 --- a/box_sdk_gen/ccg_auth.py +++ b/box_sdk_gen/ccg_auth.py @@ -63,7 +63,7 @@ def __init__( self.token_storage = token_storage -class CCGAuth(Authentication): +class BoxCCGAuth(Authentication): def __init__(self, config: CCGConfig): """ :param config: diff --git a/box_sdk_gen/client.py b/box_sdk_gen/client.py index 2720108..fc06474 100644 --- a/box_sdk_gen/client.py +++ b/box_sdk_gen/client.py @@ -165,7 +165,7 @@ from box_sdk_gen.network import NetworkSession -class Client: +class BoxClient: def __init__( self, auth: Authentication, network_session: Optional[NetworkSession] = None ): diff --git a/box_sdk_gen/developer_token_auth.py b/box_sdk_gen/developer_token_auth.py index 3913226..684ac62 100644 --- a/box_sdk_gen/developer_token_auth.py +++ b/box_sdk_gen/developer_token_auth.py @@ -5,7 +5,7 @@ from .schemas import AccessToken -class DeveloperTokenAuth(Authentication): +class BoxDeveloperTokenAuth(Authentication): def __init__(self, token: str): self.token: AccessToken = AccessToken(access_token=token) diff --git a/box_sdk_gen/fetch.py b/box_sdk_gen/fetch.py index 9121e8d..f741a7b 100644 --- a/box_sdk_gen/fetch.py +++ b/box_sdk_gen/fetch.py @@ -125,7 +125,10 @@ def fetch(url: str, options: FetchOptions) -> FetchResponse: ) if response.reauthentication_needed: - options.auth.refresh_token(options.network_session) + headers['Authorization'] = ( + 'Bearer' + f' {options.auth.refresh_token(options.network_session).access_token}' + ) elif response.status_code != 429 and response.status_code < 500: __raise_on_unsuccessful_request( network_response=response.network_response, @@ -182,24 +185,27 @@ def __make_request( multipart_data, attempt_nr, ) -> APIResponse: - if content_type == 'multipart/form-data': - fields = OrderedDict() - for part in multipart_data: - if part.body: - fields[part.part_name] = part.body - else: - file_stream = part.file_stream - file_stream_position = file_stream.tell() - file_stream.seek(file_stream_position) - fields[part.part_name] = ( - part.file_name or '', - file_stream, - part.content_type, - ) - - multipart_stream = MultipartEncoder(fields) - body = multipart_stream - headers['Content-Type'] = multipart_stream.content_type + if content_type: + if content_type == 'multipart/form-data': + fields = OrderedDict() + for part in multipart_data: + if part.body: + fields[part.part_name] = part.body + else: + file_stream = part.file_stream + file_stream_position = file_stream.tell() + file_stream.seek(file_stream_position) + fields[part.part_name] = ( + part.file_name or '', + file_stream, + part.content_type, + ) + + multipart_stream = MultipartEncoder(fields) + body = multipart_stream + headers['Content-Type'] = multipart_stream.content_type + else: + headers['Content-Type'] = content_type raised_exception = None try: diff --git a/box_sdk_gen/jwt_auth.py b/box_sdk_gen/jwt_auth.py index b1437c8..a2bcb99 100644 --- a/box_sdk_gen/jwt_auth.py +++ b/box_sdk_gen/jwt_auth.py @@ -148,7 +148,7 @@ def from_config_file( ) -class JWTAuth(Authentication): +class BoxJWTAuth(Authentication): def __init__(self, config: JWTConfig): """ :param config: diff --git a/box_sdk_gen/managers/avatars.py b/box_sdk_gen/managers/avatars.py index 1772836..3e1405a 100644 --- a/box_sdk_gen/managers/avatars.py +++ b/box_sdk_gen/managers/avatars.py @@ -2,7 +2,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -109,7 +109,7 @@ def create_user_avatar( network_session=self.network_session, ), ) - return UserAvatar.from_dict(json.loads(response.text)) + return deserialize(response.text, UserAvatar) def delete_user_avatar( self, user_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/chunked_uploads.py b/box_sdk_gen/managers/chunked_uploads.py index 56b9f69..39d78de 100644 --- a/box_sdk_gen/managers/chunked_uploads.py +++ b/box_sdk_gen/managers/chunked_uploads.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -113,14 +115,14 @@ def create_file_upload_session( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return UploadSession.from_dict(json.loads(response.text)) + return deserialize(response.text, UploadSession) def create_file_upload_session_for_existing_file( self, @@ -157,14 +159,14 @@ def create_file_upload_session_for_existing_file( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return UploadSession.from_dict(json.loads(response.text)) + return deserialize(response.text, UploadSession) def get_file_upload_session_by_id( self, @@ -197,7 +199,7 @@ def get_file_upload_session_by_id( network_session=self.network_session, ), ) - return UploadSession.from_dict(json.loads(response.text)) + return deserialize(response.text, UploadSession) def upload_file_part( self, @@ -263,7 +265,7 @@ def upload_file_part( network_session=self.network_session, ), ) - return UploadedPart.from_dict(json.loads(response.text)) + return deserialize(response.text, UploadedPart) def delete_file_upload_session_by_id( self, @@ -349,7 +351,7 @@ def get_file_upload_session_parts( network_session=self.network_session, ), ) - return UploadParts.from_dict(json.loads(response.text)) + return deserialize(response.text, UploadParts) def create_file_upload_session_commit( self, @@ -414,14 +416,14 @@ def create_file_upload_session_commit( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Files.from_dict(json.loads(response.text)) + return deserialize(response.text, Files) def reducer(self, acc: PartAccumulator, chunk: ByteStream): last_index: int = acc.last_index diff --git a/box_sdk_gen/managers/classifications.py b/box_sdk_gen/managers/classifications.py index 7f3fa6e..de1e70e 100644 --- a/box_sdk_gen/managers/classifications.py +++ b/box_sdk_gen/managers/classifications.py @@ -8,7 +8,9 @@ from typing import List -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -476,7 +478,7 @@ def get_metadata_template_enterprise_security_classification_schema( network_session=self.network_session, ), ) - return ClassificationTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, ClassificationTemplate) def delete_metadata_template_enterprise_security_classification_schema( self, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -546,14 +548,14 @@ def update_metadata_template_enterprise_security_classification_schema_add( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ClassificationTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, ClassificationTemplate) def update_metadata_template_enterprise_security_classification_schema_update( self, @@ -593,14 +595,14 @@ def update_metadata_template_enterprise_security_classification_schema_update( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ClassificationTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, ClassificationTemplate) def update_metadata_template_enterprise_security_classification_schema_delete( self, @@ -640,14 +642,14 @@ def update_metadata_template_enterprise_security_classification_schema_delete( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ClassificationTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, ClassificationTemplate) def create_metadata_template_schema_classification( self, @@ -716,11 +718,11 @@ def create_metadata_template_schema_classification( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ClassificationTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, ClassificationTemplate) diff --git a/box_sdk_gen/managers/collaboration_allowlist_entries.py b/box_sdk_gen/managers/collaboration_allowlist_entries.py index 57151a3..36c1813 100644 --- a/box_sdk_gen/managers/collaboration_allowlist_entries.py +++ b/box_sdk_gen/managers/collaboration_allowlist_entries.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -83,7 +85,7 @@ def get_collaboration_whitelist_entries( network_session=self.network_session, ), ) - return CollaborationAllowlistEntries.from_dict(json.loads(response.text)) + return deserialize(response.text, CollaborationAllowlistEntries) def create_collaboration_whitelist_entry( self, @@ -112,14 +114,14 @@ def create_collaboration_whitelist_entry( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return CollaborationAllowlistEntry.from_dict(json.loads(response.text)) + return deserialize(response.text, CollaborationAllowlistEntry) def get_collaboration_whitelist_entry_by_id( self, @@ -155,7 +157,7 @@ def get_collaboration_whitelist_entry_by_id( network_session=self.network_session, ), ) - return CollaborationAllowlistEntry.from_dict(json.loads(response.text)) + return deserialize(response.text, CollaborationAllowlistEntry) def delete_collaboration_whitelist_entry_by_id( self, diff --git a/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py b/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py index 1ec9641..9cc97a1 100644 --- a/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py +++ b/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -87,7 +89,7 @@ def get_collaboration_whitelist_exempt_targets( network_session=self.network_session, ), ) - return CollaborationAllowlistExemptTargets.from_dict(json.loads(response.text)) + return deserialize(response.text, CollaborationAllowlistExemptTargets) def create_collaboration_whitelist_exempt_target( self, @@ -113,14 +115,14 @@ def create_collaboration_whitelist_exempt_target( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return CollaborationAllowlistExemptTarget.from_dict(json.loads(response.text)) + return deserialize(response.text, CollaborationAllowlistExemptTarget) def get_collaboration_whitelist_exempt_target_by_id( self, @@ -156,7 +158,7 @@ def get_collaboration_whitelist_exempt_target_by_id( network_session=self.network_session, ), ) - return CollaborationAllowlistExemptTarget.from_dict(json.loads(response.text)) + return deserialize(response.text, CollaborationAllowlistExemptTarget) def delete_collaboration_whitelist_exempt_target_by_id( self, diff --git a/box_sdk_gen/managers/collections.py b/box_sdk_gen/managers/collections.py index f212aaf..ebaa0a4 100644 --- a/box_sdk_gen/managers/collections.py +++ b/box_sdk_gen/managers/collections.py @@ -2,7 +2,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import Collections @@ -91,7 +91,7 @@ def get_collections( network_session=self.network_session, ), ) - return Collections.from_dict(json.loads(response.text)) + return deserialize(response.text, Collections) def get_collection_items( self, @@ -149,4 +149,4 @@ def get_collection_items( network_session=self.network_session, ), ) - return Items.from_dict(json.loads(response.text)) + return deserialize(response.text, Items) diff --git a/box_sdk_gen/managers/comments.py b/box_sdk_gen/managers/comments.py index ee72254..d48345c 100644 --- a/box_sdk_gen/managers/comments.py +++ b/box_sdk_gen/managers/comments.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -120,7 +122,7 @@ def get_file_comments( network_session=self.network_session, ), ) - return Comments.from_dict(json.loads(response.text)) + return deserialize(response.text, Comments) def get_comment_by_id( self, @@ -163,7 +165,7 @@ def get_comment_by_id( network_session=self.network_session, ), ) - return CommentFull.from_dict(json.loads(response.text)) + return deserialize(response.text, CommentFull) def update_comment_by_id( self, @@ -202,14 +204,14 @@ def update_comment_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return CommentFull.from_dict(json.loads(response.text)) + return deserialize(response.text, CommentFull) def delete_comment_by_id( self, comment_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -291,11 +293,11 @@ def create_comment( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Comment.from_dict(json.loads(response.text)) + return deserialize(response.text, Comment) diff --git a/box_sdk_gen/managers/device_pinners.py b/box_sdk_gen/managers/device_pinners.py index 9683749..644f5c6 100644 --- a/box_sdk_gen/managers/device_pinners.py +++ b/box_sdk_gen/managers/device_pinners.py @@ -4,7 +4,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import DevicePinner @@ -69,7 +69,7 @@ def get_device_pinner_by_id( network_session=self.network_session, ), ) - return DevicePinner.from_dict(json.loads(response.text)) + return deserialize(response.text, DevicePinner) def delete_device_pinner_by_id( self, @@ -157,4 +157,4 @@ def get_enterprise_device_pinners( network_session=self.network_session, ), ) - return DevicePinners.from_dict(json.loads(response.text)) + return deserialize(response.text, DevicePinners) diff --git a/box_sdk_gen/managers/email_aliases.py b/box_sdk_gen/managers/email_aliases.py index 23d523f..d4dfe9b 100644 --- a/box_sdk_gen/managers/email_aliases.py +++ b/box_sdk_gen/managers/email_aliases.py @@ -2,7 +2,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -65,7 +67,7 @@ def get_user_email_aliases( network_session=self.network_session, ), ) - return EmailAliases.from_dict(json.loads(response.text)) + return deserialize(response.text, EmailAliases) def create_user_email_alias( self, @@ -97,14 +99,14 @@ def create_user_email_alias( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return EmailAlias.from_dict(json.loads(response.text)) + return deserialize(response.text, EmailAlias) def delete_user_email_alias_by_id( self, diff --git a/box_sdk_gen/managers/events.py b/box_sdk_gen/managers/events.py index 165b2b8..cb4b44f 100644 --- a/box_sdk_gen/managers/events.py +++ b/box_sdk_gen/managers/events.py @@ -4,7 +4,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import Events @@ -150,7 +150,7 @@ def get_events( network_session=self.network_session, ), ) - return Events.from_dict(json.loads(response.text)) + return deserialize(response.text, Events) def get_events_with_long_polling( self, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -245,4 +245,4 @@ def get_events_with_long_polling( network_session=self.network_session, ), ) - return RealtimeServers.from_dict(json.loads(response.text)) + return deserialize(response.text, RealtimeServers) diff --git a/box_sdk_gen/managers/file_classifications.py b/box_sdk_gen/managers/file_classifications.py index a74878e..438fb13 100644 --- a/box_sdk_gen/managers/file_classifications.py +++ b/box_sdk_gen/managers/file_classifications.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from typing import List @@ -131,7 +133,7 @@ def get_file_metadata_enterprise_security_classification_6_vm_vochw_u_wo( network_session=self.network_session, ), ) - return Classification.from_dict(json.loads(response.text)) + return deserialize(response.text, Classification) def create_file_metadata_enterprise_security_classification( self, @@ -187,14 +189,14 @@ def create_file_metadata_enterprise_security_classification( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Classification.from_dict(json.loads(response.text)) + return deserialize(response.text, Classification) def update_file_metadata_enterprise_security_classification( self, @@ -242,14 +244,14 @@ def update_file_metadata_enterprise_security_classification( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Classification.from_dict(json.loads(response.text)) + return deserialize(response.text, Classification) def delete_file_metadata_enterprise_security_classification( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/file_metadata.py b/box_sdk_gen/managers/file_metadata.py index 4e1cffb..babfa9b 100644 --- a/box_sdk_gen/managers/file_metadata.py +++ b/box_sdk_gen/managers/file_metadata.py @@ -1,12 +1,14 @@ from enum import Enum +from typing import Optional + from typing import Dict from box_sdk_gen.base_object import BaseObject -from typing import Optional +from box_sdk_gen.serialization import deserialize -import json +from box_sdk_gen.serialization import serialize from typing import List @@ -45,10 +47,6 @@ class CreateFileMetadataByIdScopeArg(str, Enum): ENTERPRISE = 'enterprise' -class CreateFileMetadataByIdRequestBodyArg(BaseObject): - pass - - class UpdateFileMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' @@ -155,7 +153,7 @@ def get_file_metadata( network_session=self.network_session, ), ) - return Metadatas.from_dict(json.loads(response.text)) + return deserialize(response.text, Metadatas) def get_file_metadata_by_id( self, @@ -208,14 +206,14 @@ def get_file_metadata_by_id( network_session=self.network_session, ), ) - return MetadataFull.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataFull) def create_file_metadata_by_id( self, file_id: str, scope: CreateFileMetadataByIdScopeArg, template_key: str, - request_body: CreateFileMetadataByIdRequestBodyArg, + request_body: Dict[str, str], extra_headers: Optional[Dict[str, Optional[str]]] = None, ) -> Metadata: """ @@ -244,7 +242,7 @@ def create_file_metadata_by_id( Example: "properties" :type template_key: str :param request_body: Request body of createFileMetadataById method - :type request_body: CreateFileMetadataByIdRequestBodyArg + :type request_body: Dict[str, str] :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ @@ -265,14 +263,14 @@ def create_file_metadata_by_id( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Metadata.from_dict(json.loads(response.text)) + return deserialize(response.text, Metadata) def update_file_metadata_by_id( self, @@ -335,14 +333,14 @@ def update_file_metadata_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Metadata.from_dict(json.loads(response.text)) + return deserialize(response.text, Metadata) def delete_file_metadata_by_id( self, diff --git a/box_sdk_gen/managers/file_requests.py b/box_sdk_gen/managers/file_requests.py index 7d44513..65d37ae 100644 --- a/box_sdk_gen/managers/file_requests.py +++ b/box_sdk_gen/managers/file_requests.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -108,7 +110,7 @@ def get_file_request_by_id( network_session=self.network_session, ), ) - return FileRequest.from_dict(json.loads(response.text)) + return deserialize(response.text, FileRequest) def update_file_request_by_id( self, @@ -196,14 +198,14 @@ def update_file_request_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileRequest.from_dict(json.loads(response.text)) + return deserialize(response.text, FileRequest) def delete_file_request_by_id( self, @@ -320,11 +322,11 @@ def create_file_request_copy( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileRequest.from_dict(json.loads(response.text)) + return deserialize(response.text, FileRequest) diff --git a/box_sdk_gen/managers/file_version_legal_holds.py b/box_sdk_gen/managers/file_version_legal_holds.py index c93607d..004e6c1 100644 --- a/box_sdk_gen/managers/file_version_legal_holds.py +++ b/box_sdk_gen/managers/file_version_legal_holds.py @@ -2,7 +2,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import FileVersionLegalHold @@ -70,7 +70,7 @@ def get_file_version_legal_hold_by_id( network_session=self.network_session, ), ) - return FileVersionLegalHold.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionLegalHold) def get_file_version_legal_holds( self, @@ -156,4 +156,4 @@ def get_file_version_legal_holds( network_session=self.network_session, ), ) - return FileVersionLegalHolds.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionLegalHolds) diff --git a/box_sdk_gen/managers/file_version_retentions.py b/box_sdk_gen/managers/file_version_retentions.py index 614d4d5..921dd05 100644 --- a/box_sdk_gen/managers/file_version_retentions.py +++ b/box_sdk_gen/managers/file_version_retentions.py @@ -4,7 +4,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import FileVersionRetentions @@ -109,7 +109,7 @@ def get_file_version_retentions( network_session=self.network_session, ), ) - return FileVersionRetentions.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionRetentions) def get_file_version_retention_by_id( self, @@ -142,4 +142,4 @@ def get_file_version_retention_by_id( network_session=self.network_session, ), ) - return FileVersionRetention.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionRetention) diff --git a/box_sdk_gen/managers/file_versions.py b/box_sdk_gen/managers/file_versions.py index e0348ed..0eaf712 100644 --- a/box_sdk_gen/managers/file_versions.py +++ b/box_sdk_gen/managers/file_versions.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -108,7 +110,7 @@ def get_file_versions( network_session=self.network_session, ), ) - return FileVersions.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersions) def get_file_version_by_id( self, @@ -167,7 +169,7 @@ def get_file_version_by_id( network_session=self.network_session, ), ) - return FileVersionFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionFull) def update_file_version_by_id( self, @@ -220,14 +222,14 @@ def update_file_version_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileVersionFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionFull) def delete_file_version_by_id( self, @@ -364,11 +366,11 @@ def promote_file_version( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileVersionFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionFull) diff --git a/box_sdk_gen/managers/file_watermarks.py b/box_sdk_gen/managers/file_watermarks.py index f003de7..b398127 100644 --- a/box_sdk_gen/managers/file_watermarks.py +++ b/box_sdk_gen/managers/file_watermarks.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -84,7 +86,7 @@ def get_file_watermark( network_session=self.network_session, ), ) - return Watermark.from_dict(json.loads(response.text)) + return deserialize(response.text, Watermark) def update_file_watermark( self, @@ -116,14 +118,14 @@ def update_file_watermark( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Watermark.from_dict(json.loads(response.text)) + return deserialize(response.text, Watermark) def delete_file_watermark( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/files.py b/box_sdk_gen/managers/files.py index 601501c..0a4206e 100644 --- a/box_sdk_gen/managers/files.py +++ b/box_sdk_gen/managers/files.py @@ -6,10 +6,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import FileFull @@ -282,7 +284,7 @@ def get_file_by_id( network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def update_file_by_id( self, @@ -389,14 +391,14 @@ def update_file_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def delete_file_by_id( self, @@ -503,14 +505,14 @@ def copy_file( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def get_file_thumbnail_by_id( self, diff --git a/box_sdk_gen/managers/folder_classifications.py b/box_sdk_gen/managers/folder_classifications.py index 8892638..a7ad11d 100644 --- a/box_sdk_gen/managers/folder_classifications.py +++ b/box_sdk_gen/managers/folder_classifications.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from typing import List @@ -133,7 +135,7 @@ def get_folder_metadata_enterprise_security_classification_6_vm_vochw_u_wo( network_session=self.network_session, ), ) - return Classification.from_dict(json.loads(response.text)) + return deserialize(response.text, Classification) def create_folder_metadata_enterprise_security_classification( self, @@ -191,14 +193,14 @@ def create_folder_metadata_enterprise_security_classification( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Classification.from_dict(json.loads(response.text)) + return deserialize(response.text, Classification) def update_folder_metadata_enterprise_security_classification( self, @@ -248,14 +250,14 @@ def update_folder_metadata_enterprise_security_classification( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Classification.from_dict(json.loads(response.text)) + return deserialize(response.text, Classification) def delete_folder_metadata_enterprise_security_classification( self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/folder_locks.py b/box_sdk_gen/managers/folder_locks.py index 8ddf884..c3611b6 100644 --- a/box_sdk_gen/managers/folder_locks.py +++ b/box_sdk_gen/managers/folder_locks.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -107,7 +109,7 @@ def get_folder_locks( network_session=self.network_session, ), ) - return FolderLocks.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderLocks) def create_folder_lock( self, @@ -144,14 +146,14 @@ def create_folder_lock( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderLock.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderLock) def delete_folder_lock_by_id( self, diff --git a/box_sdk_gen/managers/folder_metadata.py b/box_sdk_gen/managers/folder_metadata.py index 07ccd77..1000260 100644 --- a/box_sdk_gen/managers/folder_metadata.py +++ b/box_sdk_gen/managers/folder_metadata.py @@ -1,12 +1,14 @@ from enum import Enum +from typing import Optional + from typing import Dict from box_sdk_gen.base_object import BaseObject -from typing import Optional +from box_sdk_gen.serialization import deserialize -import json +from box_sdk_gen.serialization import serialize from typing import List @@ -45,10 +47,6 @@ class CreateFolderMetadataByIdScopeArg(str, Enum): ENTERPRISE = 'enterprise' -class CreateFolderMetadataByIdRequestBodyArg(BaseObject): - pass - - class UpdateFolderMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' @@ -160,7 +158,7 @@ def get_folder_metadata( network_session=self.network_session, ), ) - return Metadatas.from_dict(json.loads(response.text)) + return deserialize(response.text, Metadatas) def get_folder_metadata_by_id( self, @@ -215,14 +213,14 @@ def get_folder_metadata_by_id( network_session=self.network_session, ), ) - return MetadataFull.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataFull) def create_folder_metadata_by_id( self, folder_id: str, scope: CreateFolderMetadataByIdScopeArg, template_key: str, - request_body: CreateFolderMetadataByIdRequestBodyArg, + request_body: Dict[str, str], extra_headers: Optional[Dict[str, Optional[str]]] = None, ) -> Metadata: """ @@ -262,7 +260,7 @@ def create_folder_metadata_by_id( Example: "properties" :type template_key: str :param request_body: Request body of createFolderMetadataById method - :type request_body: CreateFolderMetadataByIdRequestBodyArg + :type request_body: Dict[str, str] :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ @@ -283,14 +281,14 @@ def create_folder_metadata_by_id( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Metadata.from_dict(json.loads(response.text)) + return deserialize(response.text, Metadata) def update_folder_metadata_by_id( self, @@ -355,14 +353,14 @@ def update_folder_metadata_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Metadata.from_dict(json.loads(response.text)) + return deserialize(response.text, Metadata) def delete_folder_metadata_by_id( self, diff --git a/box_sdk_gen/managers/folder_watermarks.py b/box_sdk_gen/managers/folder_watermarks.py index ec70f96..bc50e38 100644 --- a/box_sdk_gen/managers/folder_watermarks.py +++ b/box_sdk_gen/managers/folder_watermarks.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -88,7 +90,7 @@ def get_folder_watermark( network_session=self.network_session, ), ) - return Watermark.from_dict(json.loads(response.text)) + return deserialize(response.text, Watermark) def update_folder_watermark( self, @@ -122,14 +124,14 @@ def update_folder_watermark( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Watermark.from_dict(json.loads(response.text)) + return deserialize(response.text, Watermark) def delete_folder_watermark( self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/folders.py b/box_sdk_gen/managers/folders.py index 88c209f..442d73a 100644 --- a/box_sdk_gen/managers/folders.py +++ b/box_sdk_gen/managers/folders.py @@ -6,10 +6,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import FolderFull @@ -382,7 +384,7 @@ def get_folder_by_id( network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def update_folder_by_id( self, @@ -504,14 +506,14 @@ def update_folder_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def delete_folder_by_id( self, @@ -699,7 +701,7 @@ def get_folder_items( network_session=self.network_session, ), ) - return Items.from_dict(json.loads(response.text)) + return deserialize(response.text, Items) def create_folder( self, @@ -754,14 +756,14 @@ def create_folder( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def copy_folder( self, @@ -818,11 +820,11 @@ def copy_folder( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) diff --git a/box_sdk_gen/managers/groups.py b/box_sdk_gen/managers/groups.py index 3c3a4de..9b12f6f 100644 --- a/box_sdk_gen/managers/groups.py +++ b/box_sdk_gen/managers/groups.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -123,7 +125,7 @@ def get_groups( network_session=self.network_session, ), ) - return Groups.from_dict(json.loads(response.text)) + return deserialize(response.text, Groups) def create_group( self, @@ -209,14 +211,14 @@ def create_group( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Group.from_dict(json.loads(response.text)) + return deserialize(response.text, Group) def get_group_by_id( self, @@ -262,7 +264,7 @@ def get_group_by_id( network_session=self.network_session, ), ) - return GroupFull.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupFull) def update_group_by_id( self, @@ -357,14 +359,14 @@ def update_group_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return GroupFull.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupFull) def delete_group_by_id( self, group_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/integration_mappings.py b/box_sdk_gen/managers/integration_mappings.py index f8c469a..0ca8311 100644 --- a/box_sdk_gen/managers/integration_mappings.py +++ b/box_sdk_gen/managers/integration_mappings.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.schemas import IntegrationMappingPartnerItemSlack @@ -121,7 +123,7 @@ def get_integration_mapping_slack( network_session=self.network_session, ), ) - return IntegrationMappings.from_dict(json.loads(response.text)) + return deserialize(response.text, IntegrationMappings) def create_integration_mapping_slack( self, @@ -155,14 +157,14 @@ def create_integration_mapping_slack( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return IntegrationMapping.from_dict(json.loads(response.text)) + return deserialize(response.text, IntegrationMapping) def update_integration_mapping_slack_by_id( self, @@ -202,14 +204,14 @@ def update_integration_mapping_slack_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return IntegrationMapping.from_dict(json.loads(response.text)) + return deserialize(response.text, IntegrationMapping) def delete_integration_mapping_slack_by_id( self, diff --git a/box_sdk_gen/managers/invites.py b/box_sdk_gen/managers/invites.py index febb5e3..0211abd 100644 --- a/box_sdk_gen/managers/invites.py +++ b/box_sdk_gen/managers/invites.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -112,14 +114,14 @@ def create_invite( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Invite.from_dict(json.loads(response.text)) + return deserialize(response.text, Invite) def get_invite_by_id( self, @@ -159,4 +161,4 @@ def get_invite_by_id( network_session=self.network_session, ), ) - return Invite.from_dict(json.loads(response.text)) + return deserialize(response.text, Invite) diff --git a/box_sdk_gen/managers/legal_hold_policies.py b/box_sdk_gen/managers/legal_hold_policies.py index 2c77c95..752876e 100644 --- a/box_sdk_gen/managers/legal_hold_policies.py +++ b/box_sdk_gen/managers/legal_hold_policies.py @@ -2,7 +2,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -94,7 +96,7 @@ def get_legal_hold_policies( network_session=self.network_session, ), ) - return LegalHoldPolicies.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicies) def create_legal_hold_policy( self, @@ -155,14 +157,14 @@ def create_legal_hold_policy( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return LegalHoldPolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicy) def get_legal_hold_policy_by_id( self, @@ -192,7 +194,7 @@ def get_legal_hold_policy_by_id( network_session=self.network_session, ), ) - return LegalHoldPolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicy) def update_legal_hold_policy_by_id( self, @@ -231,14 +233,14 @@ def update_legal_hold_policy_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return LegalHoldPolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicy) def delete_legal_hold_policy_by_id( self, diff --git a/box_sdk_gen/managers/legal_hold_policy_assignments.py b/box_sdk_gen/managers/legal_hold_policy_assignments.py index 6568983..1b1376d 100644 --- a/box_sdk_gen/managers/legal_hold_policy_assignments.py +++ b/box_sdk_gen/managers/legal_hold_policy_assignments.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -138,7 +140,7 @@ def get_legal_hold_policy_assignments( network_session=self.network_session, ), ) - return LegalHoldPolicyAssignments.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicyAssignments) def create_legal_hold_policy_assignment( self, @@ -164,14 +166,14 @@ def create_legal_hold_policy_assignment( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return LegalHoldPolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicyAssignment) def get_legal_hold_policy_assignment_by_id( self, @@ -204,7 +206,7 @@ def get_legal_hold_policy_assignment_by_id( network_session=self.network_session, ), ) - return LegalHoldPolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, LegalHoldPolicyAssignment) def delete_legal_hold_policy_assignment_by_id( self, @@ -339,7 +341,7 @@ def get_legal_hold_policy_assignment_file_on_hold( network_session=self.network_session, ), ) - return FileVersionLegalHolds.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionLegalHolds) def get_legal_hold_policy_assignment_file_version_on_hold( self, @@ -435,4 +437,4 @@ def get_legal_hold_policy_assignment_file_version_on_hold( network_session=self.network_session, ), ) - return FileVersionLegalHolds.from_dict(json.loads(response.text)) + return deserialize(response.text, FileVersionLegalHolds) diff --git a/box_sdk_gen/managers/list_collaborations.py b/box_sdk_gen/managers/list_collaborations.py index 5076f25..5a6ce2e 100644 --- a/box_sdk_gen/managers/list_collaborations.py +++ b/box_sdk_gen/managers/list_collaborations.py @@ -4,7 +4,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import Collaborations @@ -103,7 +103,7 @@ def get_file_collaborations( network_session=self.network_session, ), ) - return Collaborations.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaborations) def get_folder_collaborations( self, @@ -154,7 +154,7 @@ def get_folder_collaborations( network_session=self.network_session, ), ) - return Collaborations.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaborations) def get_collaborations( self, @@ -209,7 +209,7 @@ def get_collaborations( network_session=self.network_session, ), ) - return Collaborations.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaborations) def get_group_collaborations( self, @@ -259,4 +259,4 @@ def get_group_collaborations( network_session=self.network_session, ), ) - return Collaborations.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaborations) diff --git a/box_sdk_gen/managers/memberships.py b/box_sdk_gen/managers/memberships.py index 89e00c3..4dbd0a7 100644 --- a/box_sdk_gen/managers/memberships.py +++ b/box_sdk_gen/managers/memberships.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -117,7 +119,7 @@ def get_user_memberships( network_session=self.network_session, ), ) - return GroupMemberships.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupMemberships) def get_group_memberships( self, @@ -164,7 +166,7 @@ def get_group_memberships( network_session=self.network_session, ), ) - return GroupMemberships.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupMemberships) def create_group_membership( self, @@ -223,14 +225,14 @@ def create_group_membership( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return GroupMembership.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupMembership) def get_group_membership_by_id( self, @@ -278,7 +280,7 @@ def get_group_membership_by_id( network_session=self.network_session, ), ) - return GroupMembership.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupMembership) def update_group_membership_by_id( self, @@ -337,14 +339,14 @@ def update_group_membership_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return GroupMembership.from_dict(json.loads(response.text)) + return deserialize(response.text, GroupMembership) def delete_group_membership_by_id( self, diff --git a/box_sdk_gen/managers/metadata_cascade_policies.py b/box_sdk_gen/managers/metadata_cascade_policies.py index a07eb1d..69d4480 100644 --- a/box_sdk_gen/managers/metadata_cascade_policies.py +++ b/box_sdk_gen/managers/metadata_cascade_policies.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -109,7 +111,7 @@ def get_metadata_cascade_policies( network_session=self.network_session, ), ) - return MetadataCascadePolicies.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataCascadePolicies) def create_metadata_cascade_policy( self, @@ -166,14 +168,14 @@ def create_metadata_cascade_policy( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return MetadataCascadePolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataCascadePolicy) def get_metadata_cascade_policy_by_id( self, @@ -206,7 +208,7 @@ def get_metadata_cascade_policy_by_id( network_session=self.network_session, ), ) - return MetadataCascadePolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataCascadePolicy) def delete_metadata_cascade_policy_by_id( self, @@ -286,7 +288,7 @@ def create_metadata_cascade_policy_apply( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format=None, auth=self.auth, diff --git a/box_sdk_gen/managers/metadata_templates.py b/box_sdk_gen/managers/metadata_templates.py index d92d1e4..8dcb7fb 100644 --- a/box_sdk_gen/managers/metadata_templates.py +++ b/box_sdk_gen/managers/metadata_templates.py @@ -8,7 +8,9 @@ from box_sdk_gen.base_object import BaseObject -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -249,7 +251,7 @@ def get_metadata_templates( network_session=self.network_session, ), ) - return MetadataTemplates.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplates) def get_metadata_template_schema( self, @@ -295,7 +297,7 @@ def get_metadata_template_schema( network_session=self.network_session, ), ) - return MetadataTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplate) def update_metadata_template_schema( self, @@ -345,14 +347,14 @@ def update_metadata_template_schema( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return MetadataTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplate) def delete_metadata_template_schema( self, @@ -421,7 +423,7 @@ def get_metadata_template_by_id( network_session=self.network_session, ), ) - return MetadataTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplate) def get_metadata_template_global( self, @@ -460,7 +462,7 @@ def get_metadata_template_global( network_session=self.network_session, ), ) - return MetadataTemplates.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplates) def get_metadata_template_enterprise( self, @@ -499,7 +501,7 @@ def get_metadata_template_enterprise( network_session=self.network_session, ), ) - return MetadataTemplates.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplates) def create_metadata_template_schema( self, @@ -560,11 +562,11 @@ def create_metadata_template_schema( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return MetadataTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataTemplate) diff --git a/box_sdk_gen/managers/recent_items.py b/box_sdk_gen/managers/recent_items.py index b33b97e..5460450 100644 --- a/box_sdk_gen/managers/recent_items.py +++ b/box_sdk_gen/managers/recent_items.py @@ -2,7 +2,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import RecentItems @@ -88,4 +88,4 @@ def get_recent_items( network_session=self.network_session, ), ) - return RecentItems.from_dict(json.loads(response.text)) + return deserialize(response.text, RecentItems) diff --git a/box_sdk_gen/managers/retention_policies.py b/box_sdk_gen/managers/retention_policies.py index 2cc9354..7d2e99a 100644 --- a/box_sdk_gen/managers/retention_policies.py +++ b/box_sdk_gen/managers/retention_policies.py @@ -4,10 +4,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import RetentionPolicies @@ -129,7 +131,7 @@ def get_retention_policies( network_session=self.network_session, ), ) - return RetentionPolicies.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicies) def create_retention_policy( self, @@ -215,14 +217,14 @@ def create_retention_policy( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return RetentionPolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicy) def get_retention_policy_by_id( self, @@ -264,7 +266,7 @@ def get_retention_policy_by_id( network_session=self.network_session, ), ) - return RetentionPolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicy) def update_retention_policy_by_id( self, @@ -361,14 +363,14 @@ def update_retention_policy_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return RetentionPolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicy) def delete_retention_policy_by_id( self, diff --git a/box_sdk_gen/managers/retention_policy_assignments.py b/box_sdk_gen/managers/retention_policy_assignments.py index 713975b..f161805 100644 --- a/box_sdk_gen/managers/retention_policy_assignments.py +++ b/box_sdk_gen/managers/retention_policy_assignments.py @@ -6,10 +6,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import RetentionPolicyAssignments @@ -158,7 +160,7 @@ def get_retention_policy_assignments( network_session=self.network_session, ), ) - return RetentionPolicyAssignments.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicyAssignments) def create_retention_policy_assignment( self, @@ -202,14 +204,14 @@ def create_retention_policy_assignment( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return RetentionPolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicyAssignment) def get_retention_policy_assignment_by_id( self, @@ -254,7 +256,7 @@ def get_retention_policy_assignment_by_id( network_session=self.network_session, ), ) - return RetentionPolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, RetentionPolicyAssignment) def delete_retention_policy_assignment_by_id( self, @@ -336,7 +338,7 @@ def get_retention_policy_assignment_file_under_retention( network_session=self.network_session, ), ) - return FilesUnderRetention.from_dict(json.loads(response.text)) + return deserialize(response.text, FilesUnderRetention) def get_retention_policy_assignment_file_version_under_retention( self, @@ -385,4 +387,4 @@ def get_retention_policy_assignment_file_version_under_retention( network_session=self.network_session, ), ) - return FilesUnderRetention.from_dict(json.loads(response.text)) + return deserialize(response.text, FilesUnderRetention) diff --git a/box_sdk_gen/managers/search.py b/box_sdk_gen/managers/search.py index cc48d84..6ef9bbb 100644 --- a/box_sdk_gen/managers/search.py +++ b/box_sdk_gen/managers/search.py @@ -8,7 +8,9 @@ from typing import List -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -207,14 +209,14 @@ def create_metadata_query_execute_read( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return MetadataQueryResults.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataQueryResults) def get_metadata_query_indices( self, @@ -248,7 +250,7 @@ def get_metadata_query_indices( network_session=self.network_session, ), ) - return MetadataQueryIndices.from_dict(json.loads(response.text)) + return deserialize(response.text, MetadataQueryIndices) def get_search( self, diff --git a/box_sdk_gen/managers/session_termination.py b/box_sdk_gen/managers/session_termination.py index 2e15a45..46b04c5 100644 --- a/box_sdk_gen/managers/session_termination.py +++ b/box_sdk_gen/managers/session_termination.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -71,14 +73,14 @@ def create_user_terminate_session( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return SessionTerminationMessage.from_dict(json.loads(response.text)) + return deserialize(response.text, SessionTerminationMessage) def create_group_terminate_session( self, @@ -110,11 +112,11 @@ def create_group_terminate_session( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return SessionTerminationMessage.from_dict(json.loads(response.text)) + return deserialize(response.text, SessionTerminationMessage) diff --git a/box_sdk_gen/managers/shared_links_files.py b/box_sdk_gen/managers/shared_links_files.py index abd1e1a..7b175f8 100644 --- a/box_sdk_gen/managers/shared_links_files.py +++ b/box_sdk_gen/managers/shared_links_files.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -290,7 +292,7 @@ def get_shared_items( network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def get_file_get_shared_link( self, @@ -329,7 +331,7 @@ def get_file_get_shared_link( network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def update_file_add_shared_link( self, @@ -369,14 +371,14 @@ def update_file_add_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def update_file_update_shared_link( self, @@ -414,14 +416,14 @@ def update_file_update_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) def update_file_remove_shared_link( self, @@ -460,11 +462,11 @@ def update_file_remove_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FileFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FileFull) diff --git a/box_sdk_gen/managers/shared_links_folders.py b/box_sdk_gen/managers/shared_links_folders.py index f09d407..80b78f9 100644 --- a/box_sdk_gen/managers/shared_links_folders.py +++ b/box_sdk_gen/managers/shared_links_folders.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -278,7 +280,7 @@ def get_shared_item_folders( network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def get_folder_get_shared_link( self, @@ -321,7 +323,7 @@ def get_folder_get_shared_link( network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def update_folder_add_shared_link( self, @@ -365,14 +367,14 @@ def update_folder_add_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def update_folder_update_shared_link( self, @@ -414,14 +416,14 @@ def update_folder_update_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) def update_folder_remove_shared_link( self, @@ -464,11 +466,11 @@ def update_folder_remove_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) diff --git a/box_sdk_gen/managers/shared_links_web_links.py b/box_sdk_gen/managers/shared_links_web_links.py index 4b6f8d5..31acee7 100644 --- a/box_sdk_gen/managers/shared_links_web_links.py +++ b/box_sdk_gen/managers/shared_links_web_links.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -276,7 +278,7 @@ def get_shared_item_web_links( network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def get_web_link_get_shared_link( self, @@ -312,7 +314,7 @@ def get_web_link_get_shared_link( network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def update_web_link_add_shared_link( self, @@ -349,14 +351,14 @@ def update_web_link_add_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def update_web_link_update_shared_link( self, @@ -395,14 +397,14 @@ def update_web_link_update_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def update_web_link_remove_shared_link( self, @@ -442,11 +444,11 @@ def update_web_link_remove_shared_link( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) diff --git a/box_sdk_gen/managers/shield_information_barrier_reports.py b/box_sdk_gen/managers/shield_information_barrier_reports.py index 6a549d5..4510ede 100644 --- a/box_sdk_gen/managers/shield_information_barrier_reports.py +++ b/box_sdk_gen/managers/shield_information_barrier_reports.py @@ -2,7 +2,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import ShieldInformationBarrierBase @@ -104,14 +106,14 @@ def create_shield_information_barrier_report( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrierReport.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrierReport) def get_shield_information_barrier_report_by_id( self, @@ -144,4 +146,4 @@ def get_shield_information_barrier_report_by_id( network_session=self.network_session, ), ) - return ShieldInformationBarrierReport.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrierReport) diff --git a/box_sdk_gen/managers/shield_information_barrier_segment_members.py b/box_sdk_gen/managers/shield_information_barrier_segment_members.py index d872523..1e6b22f 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segment_members.py +++ b/box_sdk_gen/managers/shield_information_barrier_segment_members.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -113,9 +115,7 @@ def get_shield_information_barrier_segment_member_by_id( network_session=self.network_session, ), ) - return ShieldInformationBarrierSegmentMember.from_dict( - json.loads(response.text) - ) + return deserialize(response.text, ShieldInformationBarrierSegmentMember) def delete_shield_information_barrier_segment_member_by_id( self, @@ -237,13 +237,11 @@ def create_shield_information_barrier_segment_member( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrierSegmentMember.from_dict( - json.loads(response.text) - ) + return deserialize(response.text, ShieldInformationBarrierSegmentMember) diff --git a/box_sdk_gen/managers/shield_information_barrier_segment_restrictions.py b/box_sdk_gen/managers/shield_information_barrier_segment_restrictions.py index b2991ed..87a1dd0 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segment_restrictions.py +++ b/box_sdk_gen/managers/shield_information_barrier_segment_restrictions.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -139,9 +141,7 @@ def get_shield_information_barrier_segment_restriction_by_id( network_session=self.network_session, ), ) - return ShieldInformationBarrierSegmentRestriction.from_dict( - json.loads(response.text) - ) + return deserialize(response.text, ShieldInformationBarrierSegmentRestriction) def delete_shield_information_barrier_segment_restriction_by_id( self, @@ -274,13 +274,11 @@ def create_shield_information_barrier_segment_restriction( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrierSegmentRestriction.from_dict( - json.loads(response.text) - ) + return deserialize(response.text, ShieldInformationBarrierSegmentRestriction) diff --git a/box_sdk_gen/managers/shield_information_barrier_segments.py b/box_sdk_gen/managers/shield_information_barrier_segments.py index 49e280b..fa70626 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segments.py +++ b/box_sdk_gen/managers/shield_information_barrier_segments.py @@ -2,7 +2,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -69,7 +71,7 @@ def get_shield_information_barrier_segment_by_id( network_session=self.network_session, ), ) - return ShieldInformationBarrierSegment.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrierSegment) def update_shield_information_barrier_segment_by_id( self, @@ -105,14 +107,14 @@ def update_shield_information_barrier_segment_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrierSegment.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrierSegment) def delete_shield_information_barrier_segment_by_id( self, @@ -227,11 +229,11 @@ def create_shield_information_barrier_segment( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrierSegment.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrierSegment) diff --git a/box_sdk_gen/managers/shield_information_barriers.py b/box_sdk_gen/managers/shield_information_barriers.py index d2ff7dd..4527877 100644 --- a/box_sdk_gen/managers/shield_information_barriers.py +++ b/box_sdk_gen/managers/shield_information_barriers.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -90,7 +92,7 @@ def get_shield_information_barrier_by_id( network_session=self.network_session, ), ) - return ShieldInformationBarrier.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrier) def create_shield_information_barrier_change_status( self, @@ -118,14 +120,14 @@ def create_shield_information_barrier_change_status( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrier.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrier) def get_shield_information_barriers( self, @@ -224,11 +226,11 @@ def create_shield_information_barrier( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ShieldInformationBarrier.from_dict(json.loads(response.text)) + return deserialize(response.text, ShieldInformationBarrier) diff --git a/box_sdk_gen/managers/sign_requests.py b/box_sdk_gen/managers/sign_requests.py index fe6bcec..fccb58b 100644 --- a/box_sdk_gen/managers/sign_requests.py +++ b/box_sdk_gen/managers/sign_requests.py @@ -2,10 +2,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.schemas import FileBase from box_sdk_gen.schemas import SignRequestCreateSigner @@ -78,7 +80,7 @@ def cancel_sign_request( network_session=self.network_session, ), ) - return SignRequest.from_dict(json.loads(response.text)) + return deserialize(response.text, SignRequest) def resend_sign_request( self, @@ -136,7 +138,7 @@ def get_sign_request_by_id( network_session=self.network_session, ), ) - return SignRequest.from_dict(json.loads(response.text)) + return deserialize(response.text, SignRequest) def get_sign_requests( self, @@ -175,7 +177,7 @@ def get_sign_requests( network_session=self.network_session, ), ) - return SignRequests.from_dict(json.loads(response.text)) + return deserialize(response.text, SignRequests) def create_sign_request( self, @@ -262,11 +264,11 @@ def create_sign_request( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return SignRequest.from_dict(json.loads(response.text)) + return deserialize(response.text, SignRequest) diff --git a/box_sdk_gen/managers/sign_templates.py b/box_sdk_gen/managers/sign_templates.py index 074acab..1ee4d81 100644 --- a/box_sdk_gen/managers/sign_templates.py +++ b/box_sdk_gen/managers/sign_templates.py @@ -2,7 +2,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import SignTemplates @@ -70,7 +70,7 @@ def get_sign_templates( network_session=self.network_session, ), ) - return SignTemplates.from_dict(json.loads(response.text)) + return deserialize(response.text, SignTemplates) def get_sign_template_by_id( self, template_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -96,4 +96,4 @@ def get_sign_template_by_id( network_session=self.network_session, ), ) - return SignTemplate.from_dict(json.loads(response.text)) + return deserialize(response.text, SignTemplate) diff --git a/box_sdk_gen/managers/skills.py b/box_sdk_gen/managers/skills.py index e5fc607..a173310 100644 --- a/box_sdk_gen/managers/skills.py +++ b/box_sdk_gen/managers/skills.py @@ -10,7 +10,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -210,7 +212,7 @@ def get_file_metadata_global_box_skills_cards( network_session=self.network_session, ), ) - return SkillCardsMetadata.from_dict(json.loads(response.text)) + return deserialize(response.text, SkillCardsMetadata) def create_file_metadata_global_box_skills_card( self, @@ -255,14 +257,14 @@ def create_file_metadata_global_box_skills_card( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return SkillCardsMetadata.from_dict(json.loads(response.text)) + return deserialize(response.text, SkillCardsMetadata) def update_file_metadata_global_box_skills_card( self, @@ -299,14 +301,14 @@ def update_file_metadata_global_box_skills_card( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return SkillCardsMetadata.from_dict(json.loads(response.text)) + return deserialize(response.text, SkillCardsMetadata) def delete_file_metadata_global_box_skills_card( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -395,7 +397,7 @@ def update_skill_invocation_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format=None, auth=self.auth, diff --git a/box_sdk_gen/managers/storage_policies.py b/box_sdk_gen/managers/storage_policies.py index ebeeadd..906ae89 100644 --- a/box_sdk_gen/managers/storage_policies.py +++ b/box_sdk_gen/managers/storage_policies.py @@ -2,7 +2,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import StoragePolicies @@ -90,7 +90,7 @@ def get_storage_policies( network_session=self.network_session, ), ) - return StoragePolicies.from_dict(json.loads(response.text)) + return deserialize(response.text, StoragePolicies) def get_storage_policy_by_id( self, @@ -118,4 +118,4 @@ def get_storage_policy_by_id( network_session=self.network_session, ), ) - return StoragePolicy.from_dict(json.loads(response.text)) + return deserialize(response.text, StoragePolicy) diff --git a/box_sdk_gen/managers/storage_policy_assignments.py b/box_sdk_gen/managers/storage_policy_assignments.py index 8c832dc..cf3c4bc 100644 --- a/box_sdk_gen/managers/storage_policy_assignments.py +++ b/box_sdk_gen/managers/storage_policy_assignments.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -161,7 +163,7 @@ def get_storage_policy_assignments( network_session=self.network_session, ), ) - return StoragePolicyAssignments.from_dict(json.loads(response.text)) + return deserialize(response.text, StoragePolicyAssignments) def create_storage_policy_assignment( self, @@ -197,14 +199,14 @@ def create_storage_policy_assignment( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return StoragePolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, StoragePolicyAssignment) def get_storage_policy_assignment_by_id( self, @@ -237,7 +239,7 @@ def get_storage_policy_assignment_by_id( network_session=self.network_session, ), ) - return StoragePolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, StoragePolicyAssignment) def update_storage_policy_assignment_by_id( self, @@ -270,14 +272,14 @@ def update_storage_policy_assignment_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return StoragePolicyAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, StoragePolicyAssignment) def delete_storage_policy_assignment_by_id( self, diff --git a/box_sdk_gen/managers/task_assignments.py b/box_sdk_gen/managers/task_assignments.py index 0d015c6..65671c9 100644 --- a/box_sdk_gen/managers/task_assignments.py +++ b/box_sdk_gen/managers/task_assignments.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -107,7 +109,7 @@ def get_task_assignments( network_session=self.network_session, ), ) - return TaskAssignments.from_dict(json.loads(response.text)) + return deserialize(response.text, TaskAssignments) def create_task_assignment( self, @@ -139,14 +141,14 @@ def create_task_assignment( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TaskAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, TaskAssignment) def get_task_assignment_by_id( self, @@ -174,7 +176,7 @@ def get_task_assignment_by_id( network_session=self.network_session, ), ) - return TaskAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, TaskAssignment) def update_task_assignment_by_id( self, @@ -211,14 +213,14 @@ def update_task_assignment_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TaskAssignment.from_dict(json.loads(response.text)) + return deserialize(response.text, TaskAssignment) def delete_task_assignment_by_id( self, diff --git a/box_sdk_gen/managers/tasks.py b/box_sdk_gen/managers/tasks.py index 81569e6..ef32762 100644 --- a/box_sdk_gen/managers/tasks.py +++ b/box_sdk_gen/managers/tasks.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -116,7 +118,7 @@ def get_file_tasks( network_session=self.network_session, ), ) - return Tasks.from_dict(json.loads(response.text)) + return deserialize(response.text, Tasks) def create_task( self, @@ -169,14 +171,14 @@ def create_task( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Task.from_dict(json.loads(response.text)) + return deserialize(response.text, Task) def get_task_by_id( self, task_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -202,7 +204,7 @@ def get_task_by_id( network_session=self.network_session, ), ) - return Task.from_dict(json.loads(response.text)) + return deserialize(response.text, Task) def update_task_by_id( self, @@ -254,14 +256,14 @@ def update_task_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Task.from_dict(json.loads(response.text)) + return deserialize(response.text, Task) def delete_task_by_id( self, task_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/terms_of_service_user_statuses.py b/box_sdk_gen/managers/terms_of_service_user_statuses.py index e2f64d1..3c374cb 100644 --- a/box_sdk_gen/managers/terms_of_service_user_statuses.py +++ b/box_sdk_gen/managers/terms_of_service_user_statuses.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -118,7 +120,7 @@ def get_term_of_service_user_statuses( network_session=self.network_session, ), ) - return TermsOfServiceUserStatuses.from_dict(json.loads(response.text)) + return deserialize(response.text, TermsOfServiceUserStatuses) def create_term_of_service_user_status( self, @@ -147,14 +149,14 @@ def create_term_of_service_user_status( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TermsOfServiceUserStatus.from_dict(json.loads(response.text)) + return deserialize(response.text, TermsOfServiceUserStatus) def update_term_of_service_user_status_by_id( self, @@ -186,11 +188,11 @@ def update_term_of_service_user_status_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TermsOfServiceUserStatus.from_dict(json.loads(response.text)) + return deserialize(response.text, TermsOfServiceUserStatus) diff --git a/box_sdk_gen/managers/terms_of_services.py b/box_sdk_gen/managers/terms_of_services.py index 7f3d082..bf68395 100644 --- a/box_sdk_gen/managers/terms_of_services.py +++ b/box_sdk_gen/managers/terms_of_services.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -94,7 +96,7 @@ def get_term_of_services( network_session=self.network_session, ), ) - return TermsOfServices.from_dict(json.loads(response.text)) + return deserialize(response.text, TermsOfServices) def create_term_of_service( self, @@ -128,14 +130,14 @@ def create_term_of_service( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Task.from_dict(json.loads(response.text)) + return deserialize(response.text, Task) def get_term_of_service_by_id( self, @@ -165,7 +167,7 @@ def get_term_of_service_by_id( network_session=self.network_session, ), ) - return TermsOfService.from_dict(json.loads(response.text)) + return deserialize(response.text, TermsOfService) def update_term_of_service_by_id( self, @@ -198,11 +200,11 @@ def update_term_of_service_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TermsOfService.from_dict(json.loads(response.text)) + return deserialize(response.text, TermsOfService) diff --git a/box_sdk_gen/managers/transfer.py b/box_sdk_gen/managers/transfer.py index f23e0d0..e70c42b 100644 --- a/box_sdk_gen/managers/transfer.py +++ b/box_sdk_gen/managers/transfer.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -158,11 +160,11 @@ def transfer_owned_folder( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return FolderFull.from_dict(json.loads(response.text)) + return deserialize(response.text, FolderFull) diff --git a/box_sdk_gen/managers/trashed_files.py b/box_sdk_gen/managers/trashed_files.py index 92cda6d..5972f3c 100644 --- a/box_sdk_gen/managers/trashed_files.py +++ b/box_sdk_gen/managers/trashed_files.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -99,14 +101,14 @@ def restore_file_from_trash( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TrashFileRestored.from_dict(json.loads(response.text)) + return deserialize(response.text, TrashFileRestored) def get_file_trash( self, @@ -175,7 +177,7 @@ def get_file_trash( network_session=self.network_session, ), ) - return TrashFile.from_dict(json.loads(response.text)) + return deserialize(response.text, TrashFile) def delete_file_trash( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/trashed_folders.py b/box_sdk_gen/managers/trashed_folders.py index b3bccdd..ed694cd 100644 --- a/box_sdk_gen/managers/trashed_folders.py +++ b/box_sdk_gen/managers/trashed_folders.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -119,14 +121,14 @@ def restore_folder_from_trash( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TrashFolderRestored.from_dict(json.loads(response.text)) + return deserialize(response.text, TrashFolderRestored) def get_folder_trash( self, @@ -197,7 +199,7 @@ def get_folder_trash( network_session=self.network_session, ), ) - return TrashFolder.from_dict(json.loads(response.text)) + return deserialize(response.text, TrashFolder) def delete_folder_trash( self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/trashed_items.py b/box_sdk_gen/managers/trashed_items.py index b3d4cb6..888d182 100644 --- a/box_sdk_gen/managers/trashed_items.py +++ b/box_sdk_gen/managers/trashed_items.py @@ -4,7 +4,7 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from box_sdk_gen.schemas import Items @@ -143,4 +143,4 @@ def get_folder_trash_items( network_session=self.network_session, ), ) - return Items.from_dict(json.loads(response.text)) + return deserialize(response.text, Items) diff --git a/box_sdk_gen/managers/trashed_web_links.py b/box_sdk_gen/managers/trashed_web_links.py index e094bc1..9c4605b 100644 --- a/box_sdk_gen/managers/trashed_web_links.py +++ b/box_sdk_gen/managers/trashed_web_links.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -94,14 +96,14 @@ def create_web_link_by_id( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return TrashWebLinkRestored.from_dict(json.loads(response.text)) + return deserialize(response.text, TrashWebLinkRestored) def get_web_link_trash( self, @@ -141,7 +143,7 @@ def get_web_link_trash( network_session=self.network_session, ), ) - return TrashWebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, TrashWebLink) def delete_web_link_trash( self, web_link_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/uploads.py b/box_sdk_gen/managers/uploads.py index 4f802b0..85b8d1d 100644 --- a/box_sdk_gen/managers/uploads.py +++ b/box_sdk_gen/managers/uploads.py @@ -4,7 +4,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -212,8 +214,7 @@ def upload_file_version( headers=headers_map, multipart_data=[ MultipartItem( - part_name='attributes', - body=json.dumps(request_body.attributes.to_dict()), + part_name='attributes', body=serialize(request_body.attributes) ), MultipartItem( part_name='file', @@ -228,7 +229,7 @@ def upload_file_version( network_session=self.network_session, ), ) - return Files.from_dict(json.loads(response.text)) + return deserialize(response.text, Files) def upload_file( self, @@ -313,8 +314,7 @@ def upload_file( headers=headers_map, multipart_data=[ MultipartItem( - part_name='attributes', - body=json.dumps(request_body.attributes.to_dict()), + part_name='attributes', body=serialize(request_body.attributes) ), MultipartItem( part_name='file', @@ -329,7 +329,7 @@ def upload_file( network_session=self.network_session, ), ) - return Files.from_dict(json.loads(response.text)) + return deserialize(response.text, Files) def preflight_file_upload( self, @@ -359,11 +359,11 @@ def preflight_file_upload( FetchOptions( method='OPTIONS', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return UploadUrl.from_dict(json.loads(response.text)) + return deserialize(response.text, UploadUrl) diff --git a/box_sdk_gen/managers/user_collaborations.py b/box_sdk_gen/managers/user_collaborations.py index 0893d4b..499b78f 100644 --- a/box_sdk_gen/managers/user_collaborations.py +++ b/box_sdk_gen/managers/user_collaborations.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize + +from box_sdk_gen.serialization import serialize from box_sdk_gen.base_object import BaseObject @@ -159,7 +161,7 @@ def get_collaboration_by_id( network_session=self.network_session, ), ) - return Collaboration.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaboration) def update_collaboration_by_id( self, @@ -224,14 +226,14 @@ def update_collaboration_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Collaboration.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaboration) def delete_collaboration_by_id( self, @@ -364,11 +366,11 @@ def create_collaboration( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Collaboration.from_dict(json.loads(response.text)) + return deserialize(response.text, Collaboration) diff --git a/box_sdk_gen/managers/users.py b/box_sdk_gen/managers/users.py index d43a742..2cdea24 100644 --- a/box_sdk_gen/managers/users.py +++ b/box_sdk_gen/managers/users.py @@ -6,10 +6,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Users @@ -195,7 +197,7 @@ def get_users( network_session=self.network_session, ), ) - return Users.from_dict(json.loads(response.text)) + return deserialize(response.text, Users) def create_user( self, @@ -317,14 +319,14 @@ def create_user( method='POST', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return User.from_dict(json.loads(response.text)) + return deserialize(response.text, User) def get_user_me( self, @@ -378,7 +380,7 @@ def get_user_me( network_session=self.network_session, ), ) - return UserFull.from_dict(json.loads(response.text)) + return deserialize(response.text, UserFull) def get_user_by_id( self, @@ -442,7 +444,7 @@ def get_user_by_id( network_session=self.network_session, ), ) - return UserFull.from_dict(json.loads(response.text)) + return deserialize(response.text, UserFull) def update_user_by_id( self, @@ -588,14 +590,14 @@ def update_user_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return UserFull.from_dict(json.loads(response.text)) + return deserialize(response.text, UserFull) def delete_user_by_id( self, diff --git a/box_sdk_gen/managers/web_links.py b/box_sdk_gen/managers/web_links.py index 1b9d03f..2ead164 100644 --- a/box_sdk_gen/managers/web_links.py +++ b/box_sdk_gen/managers/web_links.py @@ -6,7 +6,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -146,14 +148,14 @@ def create_web_link( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def get_web_link_by_id( self, @@ -192,7 +194,7 @@ def get_web_link_by_id( network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def update_web_link_by_id( self, @@ -236,14 +238,14 @@ def update_web_link_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return WebLink.from_dict(json.loads(response.text)) + return deserialize(response.text, WebLink) def delete_web_link_by_id( self, web_link_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/webhooks.py b/box_sdk_gen/managers/webhooks.py index fbfa67a..58e4044 100644 --- a/box_sdk_gen/managers/webhooks.py +++ b/box_sdk_gen/managers/webhooks.py @@ -6,10 +6,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Webhooks @@ -222,7 +224,7 @@ def get_webhooks( network_session=self.network_session, ), ) - return Webhooks.from_dict(json.loads(response.text)) + return deserialize(response.text, Webhooks) def create_webhook( self, @@ -252,14 +254,14 @@ def create_webhook( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Webhook.from_dict(json.loads(response.text)) + return deserialize(response.text, Webhook) def get_webhook_by_id( self, webhook_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -285,7 +287,7 @@ def get_webhook_by_id( network_session=self.network_session, ), ) - return Webhook.from_dict(json.loads(response.text)) + return deserialize(response.text, Webhook) def update_webhook_by_id( self, @@ -319,14 +321,14 @@ def update_webhook_by_id( FetchOptions( method='PUT', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return Webhook.from_dict(json.loads(response.text)) + return deserialize(response.text, Webhook) def delete_webhook_by_id( self, webhook_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None diff --git a/box_sdk_gen/managers/workflows.py b/box_sdk_gen/managers/workflows.py index d764161..a6e9bab 100644 --- a/box_sdk_gen/managers/workflows.py +++ b/box_sdk_gen/managers/workflows.py @@ -6,10 +6,12 @@ from typing import Dict -import json +from box_sdk_gen.serialization import deserialize from typing import List +from box_sdk_gen.serialization import serialize + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Workflows @@ -192,7 +194,7 @@ def get_workflows( network_session=self.network_session, ), ) - return Workflows.from_dict(json.loads(response.text)) + return deserialize(response.text, Workflows) def create_workflow_start( self, @@ -240,7 +242,7 @@ def create_workflow_start( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format=None, auth=self.auth, diff --git a/box_sdk_gen/managers/zip_downloads.py b/box_sdk_gen/managers/zip_downloads.py index 07b75fa..0cbe325 100644 --- a/box_sdk_gen/managers/zip_downloads.py +++ b/box_sdk_gen/managers/zip_downloads.py @@ -8,7 +8,9 @@ from typing import Dict -import json +from box_sdk_gen.serialization import serialize + +from box_sdk_gen.serialization import deserialize from box_sdk_gen.base_object import BaseObject @@ -130,14 +132,14 @@ def create_zip_download( FetchOptions( method='POST', headers=headers_map, - body=json.dumps(request_body.to_dict()), + body=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return ZipDownload.from_dict(json.loads(response.text)) + return deserialize(response.text, ZipDownload) def get_zip_download_content( self, @@ -258,4 +260,4 @@ def get_zip_download_status( network_session=self.network_session, ), ) - return ZipDownloadStatus.from_dict(json.loads(response.text)) + return deserialize(response.text, ZipDownloadStatus) diff --git a/box_sdk_gen/oauth.py b/box_sdk_gen/oauth.py index 492a3b4..a7d7645 100644 --- a/box_sdk_gen/oauth.py +++ b/box_sdk_gen/oauth.py @@ -56,7 +56,7 @@ def __init__( self.scope = scope -class OAuth(Authentication): +class BoxOAuth(Authentication): OAUTH2_AUTHORIZE_URL = 'https://account.box.com/api/oauth2/authorize' def __init__(self, config: OAuthConfig): diff --git a/box_sdk_gen/schemas.py b/box_sdk_gen/schemas.py index 8aa81e2..91d4f5b 100644 --- a/box_sdk_gen/schemas.py +++ b/box_sdk_gen/schemas.py @@ -2067,7 +2067,6 @@ class MetadataFull(Metadata): 'id': '$id', 'type': '$type', 'type_version': '$typeVersion', - 'extra_data': 'extraData', **Metadata._fields_to_json_mapping, } _json_to_fields_mapping: Dict[str, str] = { @@ -2075,7 +2074,6 @@ class MetadataFull(Metadata): '$id': 'id', '$type': 'type', '$typeVersion': 'type_version', - 'extraData': 'extra_data', **Metadata._json_to_fields_mapping, } @@ -2085,7 +2083,6 @@ def __init__( id: Optional[str] = None, type: Optional[str] = None, type_version: Optional[int] = None, - extra_data: Optional[Dict[str, str]] = None, parent: Optional[str] = None, template: Optional[str] = None, scope: Optional[str] = None, @@ -2127,7 +2124,7 @@ def __init__( self.id = id self.type = type self.type_version = type_version - self.extra_data = extra_data + self.extra_data = kwargs class MetadataCascadePolicyTypeField(str, Enum): @@ -6094,20 +6091,9 @@ class FileFullAllowedInviteeRolesField(str, Enum): class FileFullMetadataField(BaseObject): - _fields_to_json_mapping: Dict[str, str] = { - 'extra_data': 'extraData', - **BaseObject._fields_to_json_mapping, - } - _json_to_fields_mapping: Dict[str, str] = { - 'extraData': 'extra_data', - **BaseObject._json_to_fields_mapping, - } - - def __init__( - self, extra_data: Optional[Dict[str, Dict[str, Metadata]]] = None, **kwargs - ): + def __init__(self, **kwargs): super().__init__(**kwargs) - self.extra_data = extra_data + self.extra_data = kwargs class FileFullRepresentationsFieldEntriesFieldContentField(BaseObject): @@ -8264,20 +8250,9 @@ def __init__( class FolderFullMetadataField(BaseObject): - _fields_to_json_mapping: Dict[str, str] = { - 'extra_data': 'extraData', - **BaseObject._fields_to_json_mapping, - } - _json_to_fields_mapping: Dict[str, str] = { - 'extraData': 'extra_data', - **BaseObject._json_to_fields_mapping, - } - - def __init__( - self, extra_data: Optional[Dict[str, Dict[str, Metadata]]] = None, **kwargs - ): + def __init__(self, **kwargs): super().__init__(**kwargs) - self.extra_data = extra_data + self.extra_data = kwargs class FolderFullAllowedSharedLinkAccessLevelsField(str, Enum): diff --git a/box_sdk_gen/serialization.py b/box_sdk_gen/serialization.py new file mode 100644 index 0000000..87e3c2d --- /dev/null +++ b/box_sdk_gen/serialization.py @@ -0,0 +1,19 @@ +import json +from typing import Union, Type + +from .base_object import BaseObject + + +def serialize(obj: Union[BaseObject, dict, list]): + if isinstance(obj, BaseObject): + obj = obj.to_dict() + if isinstance(obj, list): + obj = [ + element.to_dict() if isinstance(element, BaseObject) else element + for element in obj + ] + return json.dumps(obj) + + +def deserialize(json_str: str, type: Type[BaseObject]): + return type.from_dict(json.loads(json_str)) diff --git a/docs/authentication.md b/docs/authentication.md index 9fa00c4..39532be 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -12,7 +12,7 @@ - [Obtaining Service Account token](#obtaining-service-account-token) - [Obtaining User token](#obtaining-user-token) - [Switching between Service Account and User](#switching-between-service-account-and-user) - - [OAuth 2.0 Auth](#oauth-20-auth) + - [BoxOAuth 2.0 Auth](#oauth-20-auth) @@ -26,17 +26,17 @@ and can only be used with your own account. Therefore, they're only useful for testing an app and aren't suitable for production. You can obtain a developer token from your application's [developer console][dev_console] page. -To create a `Client` with a developer token, construct an `DeveloperTokenAuth` +To create a `BoxClient` with a developer token, construct an `BoxDeveloperTokenAuth` object with the `token` set to the developer token and construct the client with that. ```python -from box_sdk_gen.client import Client -from box_sdk_gen.developer_token_auth import DeveloperTokenAuth +from box_sdk_gen.client import BoxClient +from box_sdk_gen.developer_token_auth import BoxDeveloperTokenAuth -auth = DeveloperTokenAuth(token='DEVELOPER_TOKEN_GOES_HERE') -client = Client(auth=auth) +auth = BoxDeveloperTokenAuth(token='DEVELOPER_TOKEN_GOES_HERE') +client = BoxClient(auth=auth) me = client.users.get_user_me() print(f'My user ID is {me.id}') @@ -67,17 +67,17 @@ not accessible in any other account by default, and vice versa. If you generated your public and private keys automatically through the [Box Developer Console][dev_console], you can use the JSON file created there to configure your SDK instance and create a client to make calls as the -Service Account. Call one of static `JWTAuth` method: +Service Account. Call one of static `BoxJWTAuth` method: `JWTConfig.from_config_file(config_file_path='/path/to/settings.json')` and pass JSON file local path or `JWTConfig.from_config_json_string(config_json_string)` and pass JSON config file content as string. ```python -from box_sdk_gen.client import Client -from box_sdk_gen.jwt_auth import JWTAuth, JWTConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.jwt_auth import BoxJWTAuth, JWTConfig jwt_config = JWTConfig.from_config_file(config_file_path='/path/to/settings.json') -auth = JWTAuth(config=jwt_config) -client = Client(auth=auth) +auth = BoxJWTAuth(config=jwt_config) +client = BoxClient(auth=auth) service_account = client.users.get_user_me() print(f'Service Account user ID is {service_account.id}') @@ -86,8 +86,8 @@ print(f'Service Account user ID is {service_account.id}') Otherwise, you'll need to provide the necessary configuration fields directly to the `JWTConfig` constructor: ```python -from box_sdk_gen.client import Client -from box_sdk_gen.jwt_auth import JWTAuth, JWTConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.jwt_auth import BoxJWTAuth, JWTConfig jwt_config = JWTConfig( client_id='YOUR_CLIENT_ID', @@ -98,8 +98,8 @@ jwt_config = JWTConfig( enterprise_id='YOUR_ENTERPRISE_ID', ) -auth = JWTAuth(config=jwt_config) -service_account_client = Client(auth=auth) +auth = BoxJWTAuth(config=jwt_config) +service_account_client = BoxClient(auth=auth) ``` ### Authenticate user @@ -116,13 +116,13 @@ Clients for making calls as an App User can be created with the same JSON JWT co a user ID you want to authenticate. ```python -from box_sdk_gen.client import Client -from box_sdk_gen.jwt_auth import JWTAuth, JWTConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.jwt_auth import BoxJWTAuth, JWTConfig jwt_config = JWTConfig.from_config_file(config_file_path='/path/to/settings.json') -auth = JWTAuth(config=jwt_config) +auth = BoxJWTAuth(config=jwt_config) auth.as_user('USER_ID') -user_client = Client(auth=auth) +user_client = BoxClient(auth=auth) ``` Alternatively, clients for making calls as an App User can be created with the same `JWTConfig` @@ -130,8 +130,8 @@ constructor as in the above examples, similarly to creating a Service Account cl `user_id` instead of `enterprise_id` when constructing the auth config instance: ```python -from box_sdk_gen.client import Client -from box_sdk_gen.jwt_auth import JWTAuth, JWTConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.jwt_auth import BoxJWTAuth, JWTConfig jwt_config = JWTConfig( client_id='YOUR_CLIENT_ID', @@ -142,8 +142,8 @@ jwt_config = JWTConfig( user_id='USER_ID', ) -auth = JWTAuth(config=jwt_config) -user_client = Client(auth=auth) +auth = BoxJWTAuth(config=jwt_config) +user_client = BoxClient(auth=auth) ``` [jwt_guide]: https://developer.box.com/guides/authentication/jwt/jwt-setup/ @@ -158,11 +158,11 @@ The guide with all required steps can be found here: [Setup with Client Credenti Client Credentials Grant Auth method allows you to obtain an access token by having client credentials and secret with enterprise or user ID, which allows you to work using service or user account. -You can use `CCGAuth` to initialize a client object the same way as for other authentication types: +You can use `BoxCCGAuth` to initialize a client object the same way as for other authentication types: ```python -from box_sdk_gen.client import Client -from box_sdk_gen.ccg_auth import CCGAuth, CCGConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.ccg_auth import BoxCCGAuth, CCGConfig ccg_config = CCGConfig( @@ -170,8 +170,8 @@ ccg_config = CCGConfig( client_secret="YOUR_CLIENT_SECRET", user_id="YOUR_USER_ID" ) -auth = CCGAuth(config=ccg_config) -client = Client(auth=auth) +auth = BoxCCGAuth(config=ccg_config) +client = BoxClient(auth=auth) print(f'Id of the authenticated user is: {client.users.get_user_me().id}') ``` @@ -187,16 +187,16 @@ are not accessible in any other account by default, and vice versa. To obtain service account you will have to provide enterprise ID with client id and secret: ```python -from box_sdk_gen.client import Client -from box_sdk_gen.ccg_auth import CCGAuth, CCGConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.ccg_auth import BoxCCGAuth, CCGConfig ccg_config = CCGConfig( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", enterprise_id="YOUR_ENTERPRISE_ID" ) -auth = CCGAuth(config=ccg_config) -client = Client(auth=auth) +auth = BoxCCGAuth(config=ccg_config) +client = BoxClient(auth=auth) ``` ### Obtaining User token @@ -208,16 +208,16 @@ select `Generate user access tokens`. Do not forget to re-authorize application To obtain user account you will have to provide user ID with client id and secret. ```python -from box_sdk_gen.client import Client -from box_sdk_gen.ccg_auth import CCGAuth, CCGConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.ccg_auth import BoxCCGAuth, CCGConfig ccg_config = CCGConfig( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", user_id="YOUR_USER_ID" ) -auth = CCGAuth(config=ccg_config) -client = Client(auth=auth) +auth = BoxCCGAuth(config=ccg_config) +client = BoxClient(auth=auth) ``` ### Switching between Service Account and User @@ -254,9 +254,9 @@ browser or web view) in order to obtain an auth code. ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig -auth = OAuth( +auth = BoxOAuth( OAuthConfig(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET') ) auth_url = auth.get_authorize_url() @@ -271,24 +271,24 @@ You need to provide the auth code to the SDK to obtain an access token, then you ```python -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient auth.get_tokens_authorization_code_grant('YOUR_ACCESS_CODE') -client = Client(auth) +client = BoxClient(auth) ``` -Here you can find a Flask app example, which handles complete OAuth workflow to authenticate and +Here you can find a Flask app example, which handles complete BoxOAuth workflow to authenticate and list names of all items in a root folder. ```python from flask import Flask, request, redirect -from box_sdk_gen.client import Client -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig app = Flask(__name__) -AUTH = OAuth( +AUTH = BoxOAuth( OAuthConfig(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET') ) @@ -302,7 +302,7 @@ def get_auth(): @app.route("/oauth2callback") def callback(): AUTH.get_tokens_authorization_code_grant(request.args.get("code")) - client = Client(AUTH) + client = BoxClient(AUTH) items_in_root_folder = [item.name for item in client.folders.get_folder_items(folder_id='0').entries] return ', '.join(items_in_root_folder) @@ -319,12 +319,12 @@ if __name__ == '__main__': By default, the SDK stores the access token in volatile memory. When rerunning your application, the access token won't be reused from the previous run; a new token has to be obtained again. To use in-memory token storage, you don't need to do anything more than -create an Auth class using AuthConfig, for example, for OAuth: +create an Auth class using AuthConfig, for example, for BoxOAuth: ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig -auth = OAuth( +auth = BoxOAuth( OAuthConfig(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET') ) ``` @@ -333,13 +333,13 @@ auth = OAuth( If you want to keep an up-to-date access token in a file, allowing it to be reused after rerunning your application, you can use the `FileTokenStorage` class. To enable storing the token in a file, you need to pass an object of type -`FileTokenStorage` to the AuthConfig class. For example, for OAuth: +`FileTokenStorage` to the AuthConfig class. For example, for BoxOAuth: ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig from box_sdk_gen.token_storage import FileTokenStorage -auth = OAuth( +auth = BoxOAuth( OAuthConfig(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', token_storage=FileTokenStorage()) ) ``` @@ -349,13 +349,13 @@ auth = OAuth( If you want to keep an up-to-date access token in a file and also maintain a valid access token in in-memory cache, allowing you to reuse the token after rerunning your application while maintaining fast access times to the token, you can use the `FileWithInMemoryCacheTokenStorage` class. To enable storing the token in a file, -you need to pass an object of type `FileWithInMemoryCacheTokenStorage` to the AuthConfig class. For example, for OAuth: +you need to pass an object of type `FileWithInMemoryCacheTokenStorage` to the AuthConfig class. For example, for BoxOAuth: ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig from box_sdk_gen.token_storage import FileWithInMemoryCacheTokenStorage -auth = OAuth( +auth = BoxOAuth( OAuthConfig(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', token_storage=FileWithInMemoryCacheTokenStorage()) ) ``` @@ -366,9 +366,9 @@ You can also provide a custom token storage class. All you need to do is create and implements all of its abstract methods. Then, pass an instance of your class to the AuthConfig constructor. ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig -auth = OAuth( +auth = BoxOAuth( OAuthConfig(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', token_storage=MyCustomTokenStorage()) ) ``` diff --git a/docs/configuration.md b/docs/configuration.md index 3d875e7..a0e97c5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -13,10 +13,10 @@ The default maximum number of retries in case of failed API call is 5 (429 and > To change this number you can set `client.network.MAX_ATTEMPTS` field. ```python -from box_sdk_gen.client import Client -from box_sdk_gen.developer_token_auth import DeveloperTokenAuth +from box_sdk_gen.client import BoxClient +from box_sdk_gen.developer_token_auth import BoxDeveloperTokenAuth -auth = DeveloperTokenAuth(token='DEVELOPER_TOKEN_GOES_HERE') -client = Client(auth=auth) +auth = BoxDeveloperTokenAuth(token='DEVELOPER_TOKEN_GOES_HERE') +client = BoxClient(auth=auth) client.network.MAX_ATTEMPTS = 6 ``` diff --git a/docs/file_metadata.md b/docs/file_metadata.md index 83d8451..ecec746 100644 --- a/docs/file_metadata.md +++ b/docs/file_metadata.md @@ -15,7 +15,11 @@ This operation is performed by calling function `get_file_metadata`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-files-id-metadata/). -_Currently we don't have an example for calling `get_file_metadata` in integration tests_ + + +```python +client.file_metadata.get_file_metadata(file_id=file_id) +``` ### Arguments @@ -43,7 +47,11 @@ This operation is performed by calling function `get_file_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-files-id-metadata-id-id/). -_Currently we don't have an example for calling `get_file_metadata_by_id` in integration tests_ + + +```python +client.file_metadata.get_file_metadata_by_id(file_id=file_id, scope=scope, template_key=template) +``` ### Arguments @@ -77,7 +85,11 @@ This operation is performed by calling function `create_file_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-files-id-metadata-id-id/). -_Currently we don't have an example for calling `create_file_metadata_by_id` in integration tests_ + + +```python +client.file_metadata.create_file_metadata_by_id(file_id=file_id, scope=scope, template_key=template, request_body=data) +``` ### Arguments @@ -87,7 +99,7 @@ _Currently we don't have an example for calling `create_file_metadata_by_id` in - The scope of the metadata template Example: "global" - template_key `str` - The name of the metadata template Example: "properties" -- request_body `CreateFileMetadataByIdRequestBodyArg` +- request_body `Dict[str, str]` - Request body of createFileMetadataById method - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. @@ -115,7 +127,11 @@ This operation is performed by calling function `update_file_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/put-files-id-metadata-id-id/). -_Currently we don't have an example for calling `update_file_metadata_by_id` in integration tests_ + + +```python +client.file_metadata.update_file_metadata_by_id(file_id=file_id, scope=scope, template_key=template, request_body=[UpdateFileMetadataByIdRequestBodyArg(op=UpdateFileMetadataByIdRequestBodyArgOpField.REPLACE.value, path='/abc', value=new_value)]) +``` ### Arguments @@ -146,7 +162,11 @@ This operation is performed by calling function `delete_file_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-files-id-metadata-id-id/). -_Currently we don't have an example for calling `delete_file_metadata_by_id` in integration tests_ + + +```python +client.file_metadata.delete_file_metadata_by_id(file_id=file_id, scope=scope, template_key=template) +``` ### Arguments diff --git a/docs/folder_metadata.md b/docs/folder_metadata.md index 32abbb1..1423cdb 100644 --- a/docs/folder_metadata.md +++ b/docs/folder_metadata.md @@ -16,7 +16,11 @@ This operation is performed by calling function `get_folder_metadata`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-folders-id-metadata/). -_Currently we don't have an example for calling `get_folder_metadata` in integration tests_ + + +```python +client.folder_metadata.get_folder_metadata(folder_id=folder.id) +``` ### Arguments @@ -44,7 +48,11 @@ This operation is performed by calling function `get_folder_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-folders-id-metadata-id-id/). -_Currently we don't have an example for calling `get_folder_metadata_by_id` in integration tests_ + + +```python +client.folder_metadata.get_folder_metadata_by_id(folder_id=folder.id, scope=scope, template_key=template) +``` ### Arguments @@ -82,7 +90,11 @@ This operation is performed by calling function `create_folder_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-folders-id-metadata-id-id/). -_Currently we don't have an example for calling `create_folder_metadata_by_id` in integration tests_ + + +```python +client.folder_metadata.create_folder_metadata_by_id(folder_id=folder.id, scope=scope, template_key=template, request_body=data) +``` ### Arguments @@ -92,7 +104,7 @@ _Currently we don't have an example for calling `create_folder_metadata_by_id` i - The scope of the metadata template Example: "global" - template_key `str` - The name of the metadata template Example: "properties" -- request_body `CreateFolderMetadataByIdRequestBodyArg` +- request_body `Dict[str, str]` - Request body of createFolderMetadataById method - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. @@ -120,7 +132,11 @@ This operation is performed by calling function `update_folder_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/put-folders-id-metadata-id-id/). -_Currently we don't have an example for calling `update_folder_metadata_by_id` in integration tests_ + + +```python +client.folder_metadata.update_folder_metadata_by_id(folder_id=folder.id, scope=scope, template_key=template, request_body=[UpdateFolderMetadataByIdRequestBodyArg(op=UpdateFolderMetadataByIdRequestBodyArgOpField.REPLACE.value, path='/abc', value=new_value)]) +``` ### Arguments @@ -151,7 +167,11 @@ This operation is performed by calling function `delete_folder_metadata_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-folders-id-metadata-id-id/). -_Currently we don't have an example for calling `delete_folder_metadata_by_id` in integration tests_ + + +```python +client.folder_metadata.delete_folder_metadata_by_id(folder_id=folder.id, scope=scope, template_key=template) +``` ### Arguments diff --git a/docs/memberships.md b/docs/memberships.md index fc24eab..4e8400a 100644 --- a/docs/memberships.md +++ b/docs/memberships.md @@ -90,7 +90,7 @@ See the endpoint docs at ```python -client.memberships.create_group_membership(user=user, group=group) +client.memberships.create_group_membership(user=CreateGroupMembershipUserArg(id=user.id), group=CreateGroupMembershipGroupArg(id=group.id)) ``` ### Arguments diff --git a/migration-guide.md b/migration-guide.md index 3649eab..d5141e3 100644 --- a/migration-guide.md +++ b/migration-guide.md @@ -77,7 +77,7 @@ updated_user = user.update_info(data={'name': 'New User Name'}) **New (`box-sdk-gen`)** In the new SDK the API methods are grouped into dedicated manager classes, e.g. `User` object -has dedicated `UserManager` class. Each manager class instance is available in `Client` object. +has dedicated `UserManager` class. Each manager class instance is available in `BoxClient` object. So if you want to perform any operation connected with a `User` you need to call a respective method of `UserManager`. E.g. to get info about existing user you need to call: @@ -135,7 +135,7 @@ Let's see the differences of their usage: ### Developer Token -The new SDK provides a convenient `DeveloperTokenAuth`, which allows authenticating +The new SDK provides a convenient `BoxDeveloperTokenAuth`, which allows authenticating using developer token without necessity to provide a Client ID and Client Secret **Old (`boxsdk`)** @@ -155,10 +155,10 @@ client = Client(auth) ```python from box_sdk_gen.client import Client -from box_sdk_gen.developer_token_auth import DeveloperTokenAuth +from box_sdk_gen.developer_token_auth import BoxDeveloperTokenAuth -auth = DeveloperTokenAuth(token='DEVELOPER_TOKEN_GOES_HERE') -client = Client(auth=auth) +auth = BoxDeveloperTokenAuth(token='DEVELOPER_TOKEN_GOES_HERE') +client = BoxClient(auth=auth) ``` ### JWT Auth @@ -179,12 +179,12 @@ client = Client(auth) **New (`box-sdk-gen`)** ```python -from box_sdk_gen.client import Client -from box_sdk_gen.jwt_auth import JWTAuth, JWTConfig +from box_sdk_gen.client import BoxClient +from box_sdk_gen.jwt_auth import BoxJWTAuth, JWTConfig jwt_config = JWTConfig.from_config_file(config_file_path='/path/to/config.json') -auth = JWTAuth(config=jwt_config) -client = Client(auth=auth) +auth = BoxJWTAuth(config=jwt_config) +client = BoxClient(auth=auth) ``` #### Providing JWT configuration manually @@ -211,7 +211,7 @@ auth = JWTAuth( **New (`box-sdk-gen`)** ```python -from box_sdk_gen.jwt_auth import JWTAuth, JWTConfig +from box_sdk_gen.jwt_auth import BoxJWTAuth, JWTConfig jwt_config = JWTConfig( client_id='YOUR_CLIENT_ID', @@ -223,7 +223,7 @@ jwt_config = JWTConfig( private_key_passphrase='PASSPHRASE', jwt_algorithm='RS256', ) -auth = JWTAuth(config=jwt_config) +auth = BoxJWTAuth(config=jwt_config) ``` #### Authenticate user @@ -275,17 +275,16 @@ client = Client(auth) **New (`box-sdk-gen`)** ```python -from box_sdk_gen.client import Client -from box_sdk_gen.ccg_auth import CCGAuth, CCGConfig - +from box_sdk_gen.client import BoxClient +from box_sdk_gen.ccg_auth import BoxCCGAuth, CCGConfig ccg_config = CCGConfig( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", enterprise_id="YOUR_ENTERPRISE_ID", ) -auth = CCGAuth(config=ccg_config) -client = Client(auth=auth) +auth = BoxCCGAuth(config=ccg_config) +client = BoxClient(auth=auth) ``` #### Obtaining User token @@ -307,14 +306,14 @@ auth = CCGAuth( **New (`box-sdk-gen`)** ```python -from box_sdk_gen.ccg_auth import CCGAuth, CCGConfig +from box_sdk_gen.ccg_auth import BoxCCGAuth, CCGConfig ccg_config = CCGConfig( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", user_id="YOUR_USER_ID" ) -auth = CCGAuth(config=ccg_config) +auth = BoxCCGAuth(config=ccg_config) ``` ### Switching between Service Account and User @@ -377,9 +376,9 @@ auth_url, csrf_token = auth.get_authorization_url('http://YOUR_REDIRECT_URL') **New (`box-sdk-gen`)** ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig, GetAuthorizeUrlOptions +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig, GetAuthorizeUrlOptions -auth = OAuth( +auth = BoxOAuth( OAuthConfig( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', @@ -406,10 +405,10 @@ client = Client(auth) **New (`box-sdk-gen`)** ```python -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient access_token = auth.get_tokens_authorization_code_grant('YOUR_AUTH_CODE') -client = Client(auth) +client = BoxClient(auth) ``` ### Store token and retrieve token callbacks @@ -454,7 +453,7 @@ AuthConfig constructor. ```python from typing import Optional -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig from box_sdk_gen.token_storage import FileWithInMemoryCacheTokenStorage, TokenStorage from .schemas import AccessToken @@ -472,7 +471,7 @@ class MyCustomTokenStorage(TokenStorage): pass -auth = OAuth( +auth = BoxOAuth( OAuthConfig( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', @@ -484,10 +483,10 @@ auth = OAuth( or reuse one of the provided implementations: `FileTokenStorage` or `FileWithInMemoryCacheTokenStorage`: ```python -from box_sdk_gen.oauth import OAuth, OAuthConfig +from box_sdk_gen.oauth import BoxOAuth, OAuthConfig from box_sdk_gen.token_storage import FileWithInMemoryCacheTokenStorage -auth = OAuth( +auth = BoxOAuth( OAuthConfig( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', diff --git a/test/auth.py b/test/auth.py index 7eab004..fec307e 100644 --- a/test/auth.py +++ b/test/auth.py @@ -4,19 +4,19 @@ from box_sdk_gen.utils import get_env_var -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig -from box_sdk_gen.ccg_auth import CCGAuth +from box_sdk_gen.ccg_auth import BoxCCGAuth from box_sdk_gen.ccg_auth import CCGConfig -from box_sdk_gen.developer_token_auth import DeveloperTokenAuth +from box_sdk_gen.developer_token_auth import BoxDeveloperTokenAuth -from box_sdk_gen.oauth import OAuth +from box_sdk_gen.oauth import BoxOAuth from box_sdk_gen.oauth import OAuthConfig @@ -32,8 +32,8 @@ def test_ccg_auth(): enterprise_id=enterprise_id, user_id=user_id, ) - auth: CCGAuth = CCGAuth(config=ccg_config) - client: Client = Client(auth=auth) + auth: BoxCCGAuth = BoxCCGAuth(config=ccg_config) + client: BoxClient = BoxClient(auth=auth) auth.as_user(user_id) current_user: UserFull = client.users.get_user_me() assert current_user.id == user_id @@ -49,8 +49,8 @@ def test_jwt_auth(): jwt_config: JWTConfig = JWTConfig.from_config_json_string( decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) - auth: JWTAuth = JWTAuth(config=jwt_config) - client: Client = Client(auth=auth) + auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) + client: BoxClient = BoxClient(auth=auth) auth.as_user(user_id) current_user: UserFull = client.users.get_user_me() assert current_user.id == user_id @@ -65,11 +65,11 @@ def test_developer_token_auth(): jwt_config: JWTConfig = JWTConfig.from_config_json_string( decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) - auth: JWTAuth = JWTAuth(config=jwt_config) + auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) auth.as_user(user_id) token: AccessToken = auth.retrieve_token() - dev_auth: DeveloperTokenAuth = DeveloperTokenAuth(token=token.access_token) - client: Client = Client(auth=dev_auth) + dev_auth: BoxDeveloperTokenAuth = BoxDeveloperTokenAuth(token=token.access_token) + client: BoxClient = BoxClient(auth=dev_auth) current_user: UserFull = client.users.get_user_me() assert current_user.id == user_id @@ -78,7 +78,7 @@ def test_oauth_auth(): config: OAuthConfig = OAuthConfig( client_id='OAUTH_CLIENT_ID', client_secret='OAUTH_CLIENT_SECRET' ) - auth: OAuth = OAuth(config=config) + auth: BoxOAuth = BoxOAuth(config=config) auth_url: str = auth.get_authorize_url() expected_auth_url: str = 'https://account.box.com/api/oauth2/authorize?client_id=OAUTH_CLIENT_ID&response_type=code' assert auth_url == expected_auth_url diff --git a/test/avatars.py b/test/avatars.py index b9fca42..29ae730 100644 --- a/test/avatars.py +++ b/test/avatars.py @@ -12,9 +12,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -22,9 +22,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testAvatars(): diff --git a/test/chunked_uploads.py b/test/chunked_uploads.py index 2562d68..0c0b3fb 100644 --- a/test/chunked_uploads.py +++ b/test/chunked_uploads.py @@ -1,8 +1,8 @@ from box_sdk_gen.utils import ByteStream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -20,9 +20,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testChunkedUpload(): diff --git a/test/collaboration_allowlist_entries.py b/test/collaboration_allowlist_entries.py index 43bd075..09980c9 100644 --- a/test/collaboration_allowlist_entries.py +++ b/test/collaboration_allowlist_entries.py @@ -10,14 +10,14 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig -client: Client = Client( - auth=JWTAuth( +client: BoxClient = BoxClient( + auth=BoxJWTAuth( config=JWTConfig.from_config_json_string( decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) diff --git a/test/collaboration_allowlist_exempt_targets.py b/test/collaboration_allowlist_exempt_targets.py index 8858a57..b85452a 100644 --- a/test/collaboration_allowlist_exempt_targets.py +++ b/test/collaboration_allowlist_exempt_targets.py @@ -16,14 +16,14 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig -client: Client = Client( - auth=JWTAuth( +client: BoxClient = BoxClient( + auth=BoxJWTAuth( config=JWTConfig.from_config_json_string( decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) diff --git a/test/collections.py b/test/collections.py index 7427857..1123188 100644 --- a/test/collections.py +++ b/test/collections.py @@ -16,9 +16,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -26,9 +26,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testCollections(): diff --git a/test/comments.py b/test/comments.py index 8eac6a0..2dbe314 100644 --- a/test/comments.py +++ b/test/comments.py @@ -24,9 +24,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -35,8 +35,8 @@ def comments(): jwt_config: JWTConfig = JWTConfig.from_config_json_string( decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) - auth: JWTAuth = JWTAuth(config=jwt_config) - client: Client = Client(auth=auth) + auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) + client: BoxClient = BoxClient(auth=auth) file_size: int = 256 file_name: str = get_uuid() file_byte_stream: ByteStream = generate_byte_stream(file_size) diff --git a/test/commons.py b/test/commons.py index 483b84f..a6e39e0 100644 --- a/test/commons.py +++ b/test/commons.py @@ -20,9 +20,9 @@ from box_sdk_gen.utils import generate_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -30,9 +30,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def upload_new_file() -> File: diff --git a/test/downloads.py b/test/downloads.py index d06752a..6d6628e 100644 --- a/test/downloads.py +++ b/test/downloads.py @@ -24,9 +24,9 @@ from box_sdk_gen.utils import read_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -34,9 +34,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_download_file(): diff --git a/test/email_aliases.py b/test/email_aliases.py index cdcebd2..8a4f0b9 100644 --- a/test/email_aliases.py +++ b/test/email_aliases.py @@ -10,9 +10,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -20,9 +20,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testEmailAliases(): diff --git a/test/file_metadata.py b/test/file_metadata.py new file mode 100644 index 0000000..ab0809e --- /dev/null +++ b/test/file_metadata.py @@ -0,0 +1,94 @@ +from typing import Dict + +import pytest + +from box_sdk_gen.schemas import Files + +from box_sdk_gen.managers.uploads import UploadFileAttributesArg + +from box_sdk_gen.managers.uploads import UploadFileAttributesArgParentField + +from box_sdk_gen.schemas import Metadatas + +from box_sdk_gen.schemas import Metadata + +from box_sdk_gen.schemas import MetadataFull + +from box_sdk_gen.managers.file_metadata import UpdateFileMetadataByIdRequestBodyArg + +from box_sdk_gen.managers.file_metadata import ( + UpdateFileMetadataByIdRequestBodyArgOpField, +) + +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import generate_byte_stream + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.jwt_auth import BoxJWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + + +def testFileMetadata(): + client: BoxClient = BoxClient( + auth=BoxJWTAuth( + config=JWTConfig.from_config_json_string( + decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) + ) + ) + ) + uploaded_files: Files = client.uploads.upload_file( + attributes=UploadFileAttributesArg( + name=get_uuid(), parent=UploadFileAttributesArgParentField(id='0') + ), + file=generate_byte_stream(256), + ) + file_id: str = uploaded_files.entries[0].id + file_metadata: Metadatas = client.file_metadata.get_file_metadata(file_id=file_id) + assert len(file_metadata.entries) == 0 + scope: str = 'global' + template: str = 'properties' + data: Dict[str, str] = {'abc': 'xyz'} + created_metadata: Metadata = client.file_metadata.create_file_metadata_by_id( + file_id=file_id, scope=scope, template_key=template, request_body=data + ) + assert created_metadata.template == template + assert created_metadata.scope == scope + assert created_metadata.version == 0 + received_metadata: MetadataFull = client.file_metadata.get_file_metadata_by_id( + file_id=file_id, scope=scope, template_key=template + ) + assert received_metadata.extra_data['abc'] == data['abc'] + new_value: str = 'bar' + updated_metadata: Metadata = client.file_metadata.update_file_metadata_by_id( + file_id=file_id, + scope=scope, + template_key=template, + request_body=[ + UpdateFileMetadataByIdRequestBodyArg( + op=UpdateFileMetadataByIdRequestBodyArgOpField.REPLACE.value, + path='/abc', + value=new_value, + ) + ], + ) + received_updated_metadata: MetadataFull = ( + client.file_metadata.get_file_metadata_by_id( + file_id=file_id, scope=scope, template_key=template + ) + ) + assert received_updated_metadata.extra_data['abc'] == new_value + client.file_metadata.delete_file_metadata_by_id( + file_id=file_id, scope=scope, template_key=template + ) + with pytest.raises(Exception): + client.file_metadata.get_file_metadata_by_id( + file_id=file_id, scope=scope, template_key=template + ) + client.files.delete_file_by_id(file_id=file_id) diff --git a/test/file_versions.py b/test/file_versions.py index 8effaaa..a5b7c29 100644 --- a/test/file_versions.py +++ b/test/file_versions.py @@ -24,9 +24,9 @@ from box_sdk_gen.utils import generate_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -34,9 +34,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testCreateListGetRestoreDeleteFileVersion(): diff --git a/test/files.py b/test/files.py index 1a3aeb4..6694b04 100644 --- a/test/files.py +++ b/test/files.py @@ -8,8 +8,6 @@ from box_sdk_gen.managers.uploads import UploadFileAttributesArgParentField -from box_sdk_gen.utils import ByteStream - from box_sdk_gen.managers.files import GetFileThumbnailByIdExtensionArg from box_sdk_gen.schemas import FileFull @@ -28,24 +26,28 @@ from box_sdk_gen.utils import read_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.utils import buffer_equals -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig from test.commons import upload_new_file +from box_sdk_gen.utils import ByteStream + jwt_config: JWTConfig = JWTConfig.from_config_json_string( decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) -def upload_file(file_name, file_stream) -> File: +def upload_file(file_name: str, file_stream: ByteStream) -> File: uploaded_files: Files = client.uploads.upload_file( attributes=UploadFileAttributesArg( name=file_name, parent=UploadFileAttributesArgParentField(id='0') @@ -59,9 +61,18 @@ def testGetFileThumbnail(): thumbnail_file_name: str = get_uuid() thumbnail_content_stream: ByteStream = generate_byte_stream(1048576) thumbnail_file: File = upload_file(thumbnail_file_name, thumbnail_content_stream) - assert not client.files.get_file_thumbnail_by_id( - file_id=thumbnail_file.id, extension=GetFileThumbnailByIdExtensionArg.PNG.value - ) == read_byte_stream(thumbnail_content_stream) + assert ( + not buffer_equals( + read_byte_stream( + client.files.get_file_thumbnail_by_id( + file_id=thumbnail_file.id, + extension=GetFileThumbnailByIdExtensionArg.PNG.value, + ) + ), + read_byte_stream(thumbnail_content_stream), + ) + == True + ) client.files.delete_file_by_id(file_id=thumbnail_file.id) diff --git a/test/folder_locks.py b/test/folder_locks.py index 0f68492..232315b 100644 --- a/test/folder_locks.py +++ b/test/folder_locks.py @@ -18,9 +18,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -28,9 +28,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testFolderLocks(): diff --git a/test/folder_metadata.py b/test/folder_metadata.py new file mode 100644 index 0000000..6155534 --- /dev/null +++ b/test/folder_metadata.py @@ -0,0 +1,90 @@ +from typing import Dict + +import pytest + +from box_sdk_gen.schemas import FolderFull + +from box_sdk_gen.managers.folders import CreateFolderParentArg + +from box_sdk_gen.schemas import Metadatas + +from box_sdk_gen.schemas import Metadata + +from box_sdk_gen.schemas import MetadataFull + +from box_sdk_gen.managers.folder_metadata import UpdateFolderMetadataByIdRequestBodyArg + +from box_sdk_gen.managers.folder_metadata import ( + UpdateFolderMetadataByIdRequestBodyArgOpField, +) + +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import generate_byte_stream + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.jwt_auth import BoxJWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + + +def testFolderMetadata(): + client: BoxClient = BoxClient( + auth=BoxJWTAuth( + config=JWTConfig.from_config_json_string( + decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) + ) + ) + ) + folder: FolderFull = client.folders.create_folder( + name=get_uuid(), parent=CreateFolderParentArg(id='0') + ) + folder_metadata: Metadatas = client.folder_metadata.get_folder_metadata( + folder_id=folder.id + ) + assert len(folder_metadata.entries) == 0 + scope: str = 'global' + template: str = 'properties' + data: Dict[str, str] = {'abc': 'xyz'} + created_metadata: Metadata = client.folder_metadata.create_folder_metadata_by_id( + folder_id=folder.id, scope=scope, template_key=template, request_body=data + ) + assert created_metadata.template == template + assert created_metadata.scope == scope + assert created_metadata.version == 0 + received_metadata: MetadataFull = client.folder_metadata.get_folder_metadata_by_id( + folder_id=folder.id, scope=scope, template_key=template + ) + assert received_metadata.extra_data['abc'] == data['abc'] + new_value: str = 'bar' + updated_metadata: Metadata = client.folder_metadata.update_folder_metadata_by_id( + folder_id=folder.id, + scope=scope, + template_key=template, + request_body=[ + UpdateFolderMetadataByIdRequestBodyArg( + op=UpdateFolderMetadataByIdRequestBodyArgOpField.REPLACE.value, + path='/abc', + value=new_value, + ) + ], + ) + received_updated_metadata: MetadataFull = ( + client.folder_metadata.get_folder_metadata_by_id( + folder_id=folder.id, scope=scope, template_key=template + ) + ) + assert received_updated_metadata.extra_data['abc'] == new_value + client.folder_metadata.delete_folder_metadata_by_id( + folder_id=folder.id, scope=scope, template_key=template + ) + with pytest.raises(Exception): + client.folder_metadata.get_folder_metadata_by_id( + folder_id=folder.id, scope=scope, template_key=template + ) + client.folders.delete_folder_by_id(folder_id=folder.id) diff --git a/test/folders.py b/test/folders.py index 10607f0..d2002b1 100644 --- a/test/folders.py +++ b/test/folders.py @@ -16,9 +16,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -26,9 +26,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_get_folder_info(): diff --git a/test/groups.py b/test/groups.py index b8f61bc..82a7e18 100644 --- a/test/groups.py +++ b/test/groups.py @@ -12,9 +12,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -22,9 +22,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_get_groups(): diff --git a/test/memberships.py b/test/memberships.py index 5684dca..64cd74c 100644 --- a/test/memberships.py +++ b/test/memberships.py @@ -8,6 +8,10 @@ from box_sdk_gen.schemas import GroupMembership +from box_sdk_gen.managers.memberships import CreateGroupMembershipUserArg + +from box_sdk_gen.managers.memberships import CreateGroupMembershipGroupArg + from box_sdk_gen.managers.memberships import UpdateGroupMembershipByIdRoleArg from box_sdk_gen.utils import decode_base_64 @@ -16,9 +20,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -26,9 +30,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testMemberships(): @@ -45,14 +49,18 @@ def testMemberships(): ) assert group_memberships.total_count == 0 group_membership: GroupMembership = client.memberships.create_group_membership( - user=user, group=group + user=CreateGroupMembershipUserArg(id=user.id), + group=CreateGroupMembershipGroupArg(id=group.id), ) assert group_membership.user.id == user.id assert group_membership.group.id == group.id assert group_membership.role == 'member' - assert client.memberships.get_group_membership_by_id( - group_membership_id=group_membership.id + get_group_membership: GroupMembership = ( + client.memberships.get_group_membership_by_id( + group_membership_id=group_membership.id + ) ) + assert get_group_membership.id == group_membership.id updated_group_membership: GroupMembership = ( client.memberships.update_group_membership_by_id( group_membership_id=group_membership.id, diff --git a/test/metadata_templates.py b/test/metadata_templates.py index 2193b84..cf435c4 100644 --- a/test/metadata_templates.py +++ b/test/metadata_templates.py @@ -22,9 +22,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -32,9 +32,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testMetadataTemplates(): @@ -58,13 +58,17 @@ def testMetadataTemplates(): assert len(template.fields) == 1 assert template.fields[0].key == 'testName' assert template.fields[0].display_name == 'testName' - assert client.metadata_templates.get_metadata_template_by_id( - template_id=template.id + get_metadata_template: MetadataTemplate = ( + client.metadata_templates.get_metadata_template_by_id(template_id=template.id) ) - assert client.metadata_templates.get_metadata_template_schema( - scope=GetMetadataTemplateSchemaScopeArg.ENTERPRISE.value, - template_key=template.template_key, + assert get_metadata_template.id == template.id + get_metadata_template_schema: MetadataTemplate = ( + client.metadata_templates.get_metadata_template_schema( + scope=GetMetadataTemplateSchemaScopeArg.ENTERPRISE.value, + template_key=template.template_key, + ) ) + assert get_metadata_template_schema.id == template.id enterprise_metadata_templates: MetadataTemplates = ( client.metadata_templates.get_metadata_template_enterprise() ) diff --git a/test/recent_items.py b/test/recent_items.py index 052b6fb..287eaa9 100644 --- a/test/recent_items.py +++ b/test/recent_items.py @@ -6,9 +6,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -16,11 +16,11 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) def testRecentItems(): auth.as_user(get_env_var('USER_ID')) - client: Client = Client(auth=auth) + client: BoxClient = BoxClient(auth=auth) recent_items: RecentItems = client.recent_items.get_recent_items() assert len(recent_items.entries) >= 0 diff --git a/test/retention_policies.py b/test/retention_policies.py index bed10e5..4a25845 100644 --- a/test/retention_policies.py +++ b/test/retention_policies.py @@ -18,9 +18,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -28,9 +28,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testCreateUpdateGetDeleteRetentionPolicy(): diff --git a/test/sign_requests.py b/test/sign_requests.py index 7745f63..7698a8d 100644 --- a/test/sign_requests.py +++ b/test/sign_requests.py @@ -28,9 +28,9 @@ from box_sdk_gen.schemas import FileBase -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -38,9 +38,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_create_get_cancel_and_list_sign_request(): diff --git a/test/tasks.py b/test/tasks.py index 9ab0b67..97ab035 100644 --- a/test/tasks.py +++ b/test/tasks.py @@ -26,9 +26,9 @@ from box_sdk_gen.utils import generate_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -36,9 +36,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testCreateUpdateGetDeleteTask(): diff --git a/test/trashed_files.py b/test/trashed_files.py index b5ba4f9..d9566bf 100644 --- a/test/trashed_files.py +++ b/test/trashed_files.py @@ -24,9 +24,9 @@ from box_sdk_gen.utils import generate_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -34,9 +34,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testTrashedFiles(): diff --git a/test/trashed_folders.py b/test/trashed_folders.py index ce04b19..f15a7e1 100644 --- a/test/trashed_folders.py +++ b/test/trashed_folders.py @@ -14,9 +14,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -24,9 +24,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testTrashedFolders(): diff --git a/test/uploads.py b/test/uploads.py index 580ec72..1a41e4d 100644 --- a/test/uploads.py +++ b/test/uploads.py @@ -20,9 +20,9 @@ from box_sdk_gen.utils import read_byte_stream -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -30,9 +30,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_upload_file_and_file_version(): diff --git a/test/users.py b/test/users.py index 8da514a..5a02fbc 100644 --- a/test/users.py +++ b/test/users.py @@ -10,9 +10,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -20,9 +20,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_get_users(): diff --git a/test/webhooks.py b/test/webhooks.py index 4f36114..d9f7169 100644 --- a/test/webhooks.py +++ b/test/webhooks.py @@ -20,9 +20,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -30,9 +30,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def testWebhooksCRUD(): diff --git a/test/weblinks.py b/test/weblinks.py index 23ec413..190f70f 100644 --- a/test/weblinks.py +++ b/test/weblinks.py @@ -10,9 +10,9 @@ from box_sdk_gen.utils import get_uuid -from box_sdk_gen.client import Client +from box_sdk_gen.client import BoxClient -from box_sdk_gen.jwt_auth import JWTAuth +from box_sdk_gen.jwt_auth import BoxJWTAuth from box_sdk_gen.jwt_auth import JWTConfig @@ -20,9 +20,9 @@ decode_base_64(get_env_var('JWT_CONFIG_BASE_64')) ) -auth: JWTAuth = JWTAuth(config=jwt_config) +auth: BoxJWTAuth = BoxJWTAuth(config=jwt_config) -client: Client = Client(auth=auth) +client: BoxClient = BoxClient(auth=auth) def test_create_get_delete_weblink():