diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cf5d00..1bcaff8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,7 @@ jobs: CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} USER_ID: ${{ secrets.USER_ID }} ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }} + BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }} run: | tox @@ -67,3 +68,4 @@ jobs: CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} USER_ID: ${{ secrets.USER_ID }} ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }} + BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }} diff --git a/README.md b/README.md index 2cd5785..08caf4c 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,8 @@ if __name__ == '__main__': ### Create Custom Application -To run integration tests locally you will need a `Custom App` created at https://cloud.app.box.com/developers/console +To run integration tests locally you will need a `Custom App` created in the [Box Developer +Console](https://app.box.com/developers/console) with `Server Authentication (with JWT)` selected as authentication method. Once created you can edit properties of the application: @@ -96,6 +97,7 @@ Now select `Authorization` and submit application to be reviewed by account admi download your app configuration settings as JSON. 2. Encode configuration file to Base64, e.g. using command: `base64 -i path_to_json_file` 3. Set environment variable: `JWT_CONFIG_BASE_64` with base64 encoded jwt configuration file +4. Set environment variable: `BOX_FILE_REQUEST_ID` with ID of file request already created in the user account. ### Running tests diff --git a/box_sdk_gen/ccg_auth.py b/box_sdk_gen/ccg_auth.py index 7f01d1f..3d95877 100644 --- a/box_sdk_gen/ccg_auth.py +++ b/box_sdk_gen/ccg_auth.py @@ -112,13 +112,13 @@ def refresh_token( 'https://api.box.com/oauth2/token', FetchOptions( method='POST', - body=urlencode(request_body.to_dict()), - headers={'content-type': 'application/x-www-form-urlencoded'}, + data=request_body.to_dict(), + content_type='application/x-www-form-urlencoded', network_session=network_session, ), ) - new_token = AccessToken.from_dict(json.loads(response.text)) + new_token = AccessToken.from_dict(response.data) self.token_storage.store(new_token) return new_token diff --git a/box_sdk_gen/client.py b/box_sdk_gen/client.py index fc06474..148259c 100644 --- a/box_sdk_gen/client.py +++ b/box_sdk_gen/client.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Dict from box_sdk_gen.managers.authorization import AuthorizationManager @@ -166,9 +166,7 @@ class BoxClient: - def __init__( - self, auth: Authentication, network_session: Optional[NetworkSession] = None - ): + def __init__(self, auth: Authentication, network_session: NetworkSession = None): if network_session is None: network_session = NetworkSession() self.auth = auth @@ -381,3 +379,40 @@ def __init__( self.integration_mappings = IntegrationMappingsManager( auth=self.auth, network_session=self.network_session ) + + def with_as_user_header(self, user_id: str) -> 'BoxClient': + """ + Create a new client to impersonate user with the provided ID. All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified. + :param user_id: ID of an user to impersonate + :type user_id: str + """ + return BoxClient( + auth=self.auth, + network_session=self.network_session.with_additional_headers({ + 'As-User': user_id + }), + ) + + def with_suppressed_notifications(self) -> 'BoxClient': + """ + Create a new client with suppressed notifications. Calls made with the new client will not trigger email or webhook notifications + """ + return BoxClient( + auth=self.auth, + network_session=self.network_session.with_additional_headers({ + 'Box-Notifications': 'off' + }), + ) + + def with_extra_headers(self, extra_headers: Dict[str, str] = None) -> 'BoxClient': + """ + Create a new client with a custom set of headers that will be included in every API call + :param extra_headers: Custom set of headers that will be included in every API call + :type extra_headers: Dict[str, str], optional + """ + if extra_headers is None: + extra_headers = {} + return BoxClient( + auth=self.auth, + network_session=self.network_session.with_additional_headers(extra_headers), + ) diff --git a/box_sdk_gen/fetch.py b/box_sdk_gen/fetch.py index f741a7b..6a0cffb 100644 --- a/box_sdk_gen/fetch.py +++ b/box_sdk_gen/fetch.py @@ -15,6 +15,7 @@ from .network import NetworkSession from .auth import Authentication from .utils import ByteStream, ResponseByteStream +from .json import SerializedData, sd_to_json, sd_to_url_params, json_to_serialized_data DEFAULT_MAX_ATTEMPTS = 5 _RETRY_RANDOMIZATION_FACTOR = 0.5 @@ -30,7 +31,7 @@ @dataclass class MultipartItem: part_name: str - body: str = None + data: SerializedData = None file_stream: ByteStream = None file_name: str = '' content_type: str = None @@ -41,10 +42,10 @@ class FetchOptions: method: str = "GET" params: Dict[str, str] = None headers: Dict[str, str] = None - body: str = None + data: SerializedData = None file_stream: ByteStream = None multipart_data: List[MultipartItem] = None - content_type: str = "" + content_type: str = "application/json" response_format: Optional[str] = None auth: Authentication = None network_session: NetworkSession = None @@ -53,7 +54,7 @@ class FetchOptions: @dataclass class FetchResponse: status: int - text: Optional[str] = None + data: Optional[SerializedData] = None content: Optional[ByteStream] = None @@ -101,7 +102,7 @@ def fetch(url: str, options: FetchOptions) -> FetchResponse: method=options.method, url=url, headers=headers, - body=options.file_stream or options.body, + data=options.file_stream or options.data, content_type=options.content_type, params=params, multipart_data=options.multipart_data, @@ -120,7 +121,11 @@ def fetch(url: str, options: FetchOptions) -> FetchResponse: else: return FetchResponse( status=response.status_code, - text=response.text, + data=( + json_to_serialized_data(response.text) + if response.text + else None + ), content=io.BytesIO(response.content), ) @@ -148,7 +153,7 @@ def fetch(url: str, options: FetchOptions) -> FetchResponse: method=options.method, url=url, headers=headers, - body=options.body, + data=options.file_stream or options.data, content_type=options.content_type, params=params, multipart_data=options.multipart_data, @@ -162,7 +167,11 @@ def fetch(url: str, options: FetchOptions) -> FetchResponse: def __compose_headers_for_request(options: FetchOptions) -> Dict[str, str]: - headers = options.headers or {} + headers = {} + if options.network_session: + headers.update(options.network_session.additional_headers) + if options.headers: + headers.update(options.headers) if options.auth: headers['Authorization'] = ( 'Bearer' @@ -179,7 +188,7 @@ def __make_request( method, url, headers, - body, + data, content_type, params, multipart_data, @@ -189,8 +198,8 @@ def __make_request( if content_type == 'multipart/form-data': fields = OrderedDict() for part in multipart_data: - if part.body: - fields[part.part_name] = part.body + if part.data: + fields[part.part_name] = sd_to_json(part.data) else: file_stream = part.file_stream file_stream_position = file_stream.tell() @@ -202,18 +211,33 @@ def __make_request( ) multipart_stream = MultipartEncoder(fields) - body = multipart_stream + data = multipart_stream headers['Content-Type'] = multipart_stream.content_type else: headers['Content-Type'] = content_type + def get_data(): + if ( + content_type == 'application/json' + or content_type == 'application/json-patch+json' + ): + return sd_to_json(data) if data else None + if content_type == 'application/x-www-form-urlencoded': + return sd_to_url_params(data) + if ( + content_type == 'multipart/form-data' + or content_type == 'application/octet-stream' + ): + return data + raise + raised_exception = None try: network_response = session.request( method=method, url=url, headers=headers, - data=body, + data=get_data(), params=params, stream=True, ) diff --git a/box_sdk_gen/json.py b/box_sdk_gen/json.py new file mode 100644 index 0000000..c4f60e5 --- /dev/null +++ b/box_sdk_gen/json.py @@ -0,0 +1,18 @@ +import json +from urllib.parse import urlencode + + +class SerializedData: + pass + + +def json_to_serialized_data(data: str) -> SerializedData: + return json.loads(data) + + +def sd_to_json(data: SerializedData) -> str: + return json.dumps(data) + + +def sd_to_url_params(data: SerializedData) -> str: + return urlencode(data) diff --git a/box_sdk_gen/jwt_auth.py b/box_sdk_gen/jwt_auth.py index a2bcb99..3121da2 100644 --- a/box_sdk_gen/jwt_auth.py +++ b/box_sdk_gen/jwt_auth.py @@ -1,5 +1,4 @@ from datetime import datetime, timedelta -import json import random import string @@ -23,6 +22,7 @@ from .fetch import fetch, FetchResponse, FetchOptions from .network import NetworkSession from .schemas import AccessToken +from .json import json_to_serialized_data class JWTConfig: @@ -106,7 +106,7 @@ def from_config_json_string( :return: Auth instance configured as specified by the config dictionary. """ - config_dict: dict = json.loads(config_json_string) + config_dict: dict = json_to_serialized_data(config_json_string) if 'boxAppSettings' not in config_dict: raise ValueError('boxAppSettings not present in configuration') return cls( @@ -232,13 +232,13 @@ def refresh_token( 'https://api.box.com/oauth2/token', FetchOptions( method='POST', - body=urlencode(request_body.to_dict()), - headers={'content-type': 'application/x-www-form-urlencoded'}, + data=request_body.to_dict(), + content_type='application/x-www-form-urlencoded', network_session=network_session, ), ) - new_token = AccessToken.from_dict(json.loads(response.text)) + new_token = AccessToken.from_dict(response.data) self.token_storage.store(new_token) return new_token diff --git a/box_sdk_gen/managers/authorization.py b/box_sdk_gen/managers/authorization.py index ca74ee3..d55eabe 100644 --- a/box_sdk_gen/managers/authorization.py +++ b/box_sdk_gen/managers/authorization.py @@ -20,6 +20,8 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions @@ -99,15 +101,13 @@ def get_authorize( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'response_type': to_string(response_type), - 'client_id': to_string(client_id), - 'redirect_uri': to_string(redirect_uri), - 'state': to_string(state), - 'scope': to_string(scope), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'response_type': to_string(response_type), + 'client_id': to_string(client_id), + 'redirect_uri': to_string(redirect_uri), + 'state': to_string(state), + 'scope': to_string(scope), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://account.box.com/api/oauth2/authorize']), diff --git a/box_sdk_gen/managers/avatars.py b/box_sdk_gen/managers/avatars.py index 0ad1fb5..b4cab22 100644 --- a/box_sdk_gen/managers/avatars.py +++ b/box_sdk_gen/managers/avatars.py @@ -26,8 +26,12 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import MultipartItem +from box_sdk_gen.json import SerializedData + class AvatarsManager: def __init__( @@ -111,7 +115,7 @@ def create_user_avatar( network_session=self.network_session, ), ) - return deserialize(response.text, UserAvatar) + return deserialize(response.data, 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 e504536..b8914d8 100644 --- a/box_sdk_gen/managers/chunked_uploads.py +++ b/box_sdk_gen/managers/chunked_uploads.py @@ -44,6 +44,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.utils import generate_byte_stream_from_buffer from box_sdk_gen.utils import hex_to_base_64 @@ -117,14 +121,14 @@ def create_file_upload_session( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, UploadSession) + return deserialize(response.data, UploadSession) def create_file_upload_session_for_existing_file( self, @@ -155,24 +159,22 @@ def create_file_upload_session_for_existing_file( request_body: Dict = {'file_size': file_size, 'file_name': file_name} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/', - to_string(file_id), - '/upload_sessions', - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/', + to_string(file_id), + '/upload_sessions', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, UploadSession) + return deserialize(response.data, UploadSession) def get_file_upload_session_by_id( self, @@ -191,12 +193,10 @@ def get_file_upload_session_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/upload_sessions/', - to_string(upload_session_id), - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/upload_sessions/', + to_string(upload_session_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -205,7 +205,7 @@ def get_file_upload_session_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, UploadSession) + return deserialize(response.data, UploadSession) def upload_file_part( self, @@ -247,20 +247,16 @@ def upload_file_part( """ if extra_headers is None: extra_headers = {} - headers_map: Dict[str, str] = prepare_params( - { - 'digest': to_string(digest), - 'content-range': to_string(content_range), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'digest': to_string(digest), + 'content-range': to_string(content_range), + **extra_headers, + }) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/upload_sessions/', - to_string(upload_session_id), - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/upload_sessions/', + to_string(upload_session_id), + ]), FetchOptions( method='PUT', headers=headers_map, @@ -271,7 +267,7 @@ def upload_file_part( network_session=self.network_session, ), ) - return deserialize(response.text, UploadedPart) + return deserialize(response.data, UploadedPart) def delete_file_upload_session_by_id( self, @@ -293,12 +289,10 @@ def delete_file_upload_session_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/upload_sessions/', - to_string(upload_session_id), - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/upload_sessions/', + to_string(upload_session_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -336,18 +330,16 @@ def get_file_upload_session_parts( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'offset': to_string(offset), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'offset': to_string(offset), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/upload_sessions/', - to_string(upload_session_id), - '/parts', - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/upload_sessions/', + to_string(upload_session_id), + '/parts', + ]), FetchOptions( method='GET', params=query_params_map, @@ -357,7 +349,7 @@ def get_file_upload_session_parts( network_session=self.network_session, ), ) - return deserialize(response.text, UploadParts) + return deserialize(response.data, UploadParts) def create_file_upload_session_commit( self, @@ -403,33 +395,29 @@ def create_file_upload_session_commit( if extra_headers is None: extra_headers = {} request_body: Dict = {'parts': parts} - headers_map: Dict[str, str] = prepare_params( - { - 'digest': to_string(digest), - 'if-match': to_string(if_match), - 'if-none-match': to_string(if_none_match), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'digest': to_string(digest), + 'if-match': to_string(if_match), + 'if-none-match': to_string(if_none_match), + **extra_headers, + }) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/upload_sessions/', - to_string(upload_session_id), - '/commit', - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/upload_sessions/', + to_string(upload_session_id), + '/commit', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Files) + return deserialize(response.data, Files) def reducer(self, acc: PartAccumulator, chunk: ByteStream): last_index: int = acc.last_index @@ -442,16 +430,14 @@ def reducer(self, acc: PartAccumulator, chunk: ByteStream): chunk_size: int = buffer_length(chunk_buffer) bytes_start: int = last_index + 1 bytes_end: int = last_index + chunk_size - content_range: str = ''.join( - [ - 'bytes ', - to_string(bytes_start), - '-', - to_string(bytes_end), - '/', - to_string(acc.file_size), - ] - ) + content_range: str = ''.join([ + 'bytes ', + to_string(bytes_start), + '-', + to_string(bytes_end), + '/', + to_string(acc.file_size), + ]) uploaded_part: UploadedPart = self.upload_file_part( upload_session_id=acc.upload_session_id, request_body=generate_byte_stream_from_buffer(chunk_buffer), diff --git a/box_sdk_gen/managers/classifications.py b/box_sdk_gen/managers/classifications.py index c996f62..47d8291 100644 --- a/box_sdk_gen/managers/classifications.py +++ b/box_sdk_gen/managers/classifications.py @@ -32,6 +32,8 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataFieldClassificationField( BaseObject @@ -463,11 +465,9 @@ def get_metadata_template_enterprise_security_classification_schema( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema' - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema' + ]), FetchOptions( method='GET', headers=headers_map, @@ -476,7 +476,7 @@ def get_metadata_template_enterprise_security_classification_schema( network_session=self.network_session, ), ) - return deserialize(response.text, ClassificationTemplate) + return deserialize(response.data, ClassificationTemplate) def delete_metadata_template_enterprise_security_classification_schema( self, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -493,11 +493,9 @@ def delete_metadata_template_enterprise_security_classification_schema( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema' - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema' + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -538,22 +536,20 @@ def update_metadata_template_enterprise_security_classification_schema_add( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#add' - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#add' + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ClassificationTemplate) + return deserialize(response.data, ClassificationTemplate) def update_metadata_template_enterprise_security_classification_schema_update( self, @@ -585,22 +581,20 @@ def update_metadata_template_enterprise_security_classification_schema_update( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#update' - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#update' + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ClassificationTemplate) + return deserialize(response.data, ClassificationTemplate) def update_metadata_template_enterprise_security_classification_schema_delete( self, @@ -632,22 +626,20 @@ def update_metadata_template_enterprise_security_classification_schema_delete( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#delete' - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#delete' + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ClassificationTemplate) + return deserialize(response.data, ClassificationTemplate) def create_metadata_template_schema_classification( self, @@ -710,17 +702,17 @@ def create_metadata_template_schema_classification( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/metadata_templates/schema#classifications'] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/schema#classifications' + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ClassificationTemplate) + return deserialize(response.data, ClassificationTemplate) diff --git a/box_sdk_gen/managers/collaboration_allowlist_entries.py b/box_sdk_gen/managers/collaboration_allowlist_entries.py index d288bf5..19d5de5 100644 --- a/box_sdk_gen/managers/collaboration_allowlist_entries.py +++ b/box_sdk_gen/managers/collaboration_allowlist_entries.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateCollaborationWhitelistEntryDirectionArg(str, Enum): INBOUND = 'inbound' @@ -70,9 +74,9 @@ def get_collaboration_whitelist_entries( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/collaboration_whitelist_entries']), @@ -85,7 +89,7 @@ def get_collaboration_whitelist_entries( network_session=self.network_session, ), ) - return deserialize(response.text, CollaborationAllowlistEntries) + return deserialize(response.data, CollaborationAllowlistEntries) def create_collaboration_whitelist_entry( self, @@ -114,14 +118,14 @@ def create_collaboration_whitelist_entry( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, CollaborationAllowlistEntry) + return deserialize(response.data, CollaborationAllowlistEntry) def get_collaboration_whitelist_entry_by_id( self, @@ -143,12 +147,10 @@ def get_collaboration_whitelist_entry_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/collaboration_whitelist_entries/', - to_string(collaboration_whitelist_entry_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/collaboration_whitelist_entries/', + to_string(collaboration_whitelist_entry_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -157,7 +159,7 @@ def get_collaboration_whitelist_entry_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, CollaborationAllowlistEntry) + return deserialize(response.data, CollaborationAllowlistEntry) def delete_collaboration_whitelist_entry_by_id( self, @@ -179,12 +181,10 @@ def delete_collaboration_whitelist_entry_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/collaboration_whitelist_entries/', - to_string(collaboration_whitelist_entry_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/collaboration_whitelist_entries/', + to_string(collaboration_whitelist_entry_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py b/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py index fd1f5d0..10dd913 100644 --- a/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py +++ b/box_sdk_gen/managers/collaboration_allowlist_exempt_targets.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateCollaborationWhitelistExemptTargetUserArg(BaseObject): def __init__(self, id: str, **kwargs): @@ -74,9 +78,9 @@ def get_collaboration_whitelist_exempt_targets( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/collaboration_whitelist_exempt_targets']), @@ -89,7 +93,7 @@ def get_collaboration_whitelist_exempt_targets( network_session=self.network_session, ), ) - return deserialize(response.text, CollaborationAllowlistExemptTargets) + return deserialize(response.data, CollaborationAllowlistExemptTargets) def create_collaboration_whitelist_exempt_target( self, @@ -115,14 +119,14 @@ def create_collaboration_whitelist_exempt_target( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, CollaborationAllowlistExemptTarget) + return deserialize(response.data, CollaborationAllowlistExemptTarget) def get_collaboration_whitelist_exempt_target_by_id( self, @@ -144,12 +148,10 @@ def get_collaboration_whitelist_exempt_target_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/collaboration_whitelist_exempt_targets/', - to_string(collaboration_whitelist_exempt_target_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/collaboration_whitelist_exempt_targets/', + to_string(collaboration_whitelist_exempt_target_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -158,7 +160,7 @@ def get_collaboration_whitelist_exempt_target_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, CollaborationAllowlistExemptTarget) + return deserialize(response.data, CollaborationAllowlistExemptTarget) def delete_collaboration_whitelist_exempt_target_by_id( self, @@ -180,12 +182,10 @@ def delete_collaboration_whitelist_exempt_target_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/collaboration_whitelist_exempt_targets/', - to_string(collaboration_whitelist_exempt_target_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/collaboration_whitelist_exempt_targets/', + to_string(collaboration_whitelist_exempt_target_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/collections.py b/box_sdk_gen/managers/collections.py index 4b76003..54f2036 100644 --- a/box_sdk_gen/managers/collections.py +++ b/box_sdk_gen/managers/collections.py @@ -24,12 +24,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CollectionsManager: def __init__( @@ -76,13 +80,11 @@ def get_collections( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'offset': to_string(offset), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'offset': to_string(offset), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/collections']), @@ -95,7 +97,7 @@ def get_collections( network_session=self.network_session, ), ) - return deserialize(response.text, Collections) + return deserialize(response.data, Collections) def get_collection_items( self, @@ -134,22 +136,18 @@ def get_collection_items( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'offset': to_string(offset), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'offset': to_string(offset), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/collections/', - to_string(collection_id), - '/items', - ] - ), + ''.join([ + 'https://api.box.com/2.0/collections/', + to_string(collection_id), + '/items', + ]), FetchOptions( method='GET', params=query_params_map, @@ -159,4 +157,4 @@ def get_collection_items( network_session=self.network_session, ), ) - return deserialize(response.text, Items) + return deserialize(response.data, Items) diff --git a/box_sdk_gen/managers/comments.py b/box_sdk_gen/managers/comments.py index 22cf987..f766025 100644 --- a/box_sdk_gen/managers/comments.py +++ b/box_sdk_gen/managers/comments.py @@ -32,12 +32,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateCommentItemArgTypeField(str, Enum): FILE = 'file' @@ -105,18 +109,16 @@ def get_file_comments( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'limit': to_string(limit), - 'offset': to_string(offset), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'limit': to_string(limit), + 'offset': to_string(offset), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/files/', to_string(file_id), '/comments'] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/comments' + ]), FetchOptions( method='GET', params=query_params_map, @@ -126,7 +128,7 @@ def get_file_comments( network_session=self.network_session, ), ) - return deserialize(response.text, Comments) + return deserialize(response.data, Comments) def get_comment_by_id( self, @@ -169,7 +171,7 @@ def get_comment_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, CommentFull) + return deserialize(response.data, CommentFull) def update_comment_by_id( self, @@ -208,14 +210,14 @@ def update_comment_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, CommentFull) + return deserialize(response.data, CommentFull) def delete_comment_by_id( self, comment_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -299,11 +301,11 @@ def create_comment( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Comment) + return deserialize(response.data, Comment) diff --git a/box_sdk_gen/managers/device_pinners.py b/box_sdk_gen/managers/device_pinners.py index 319c7c0..eabfa41 100644 --- a/box_sdk_gen/managers/device_pinners.py +++ b/box_sdk_gen/managers/device_pinners.py @@ -30,6 +30,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class GetEnterpriseDevicePinnersDirectionArg(str, Enum): ASC = 'ASC' @@ -62,9 +66,9 @@ def get_device_pinner_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/device_pinners/', to_string(device_pinner_id)] - ), + ''.join([ + 'https://api.box.com/2.0/device_pinners/', to_string(device_pinner_id) + ]), FetchOptions( method='GET', headers=headers_map, @@ -73,7 +77,7 @@ def get_device_pinner_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, DevicePinner) + return deserialize(response.data, DevicePinner) def delete_device_pinner_by_id( self, @@ -92,9 +96,9 @@ def delete_device_pinner_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/device_pinners/', to_string(device_pinner_id)] - ), + ''.join([ + 'https://api.box.com/2.0/device_pinners/', to_string(device_pinner_id) + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -138,22 +142,18 @@ def get_enterprise_device_pinners( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'marker': to_string(marker), - 'limit': to_string(limit), - 'direction': to_string(direction), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), + 'limit': to_string(limit), + 'direction': to_string(direction), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/enterprises/', - to_string(enterprise_id), - '/device_pinners', - ] - ), + ''.join([ + 'https://api.box.com/2.0/enterprises/', + to_string(enterprise_id), + '/device_pinners', + ]), FetchOptions( method='GET', params=query_params_map, @@ -163,4 +163,4 @@ def get_enterprise_device_pinners( network_session=self.network_session, ), ) - return deserialize(response.text, DevicePinners) + return deserialize(response.data, DevicePinners) diff --git a/box_sdk_gen/managers/downloads.py b/box_sdk_gen/managers/downloads.py index a75fdb6..3833e92 100644 --- a/box_sdk_gen/managers/downloads.py +++ b/box_sdk_gen/managers/downloads.py @@ -16,6 +16,8 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions @@ -73,12 +75,12 @@ def download_file( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'version': to_string(version), 'access_token': to_string(access_token)} - ) - headers_map: Dict[str, str] = prepare_params( - {'range': to_string(range), 'boxapi': to_string(boxapi), **extra_headers} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'version': to_string(version), 'access_token': to_string(access_token) + }) + headers_map: Dict[str, str] = prepare_params({ + 'range': to_string(range), 'boxapi': to_string(boxapi), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/files/', to_string(file_id), '/content']), FetchOptions( diff --git a/box_sdk_gen/managers/email_aliases.py b/box_sdk_gen/managers/email_aliases.py index 4731be9..7b67e0f 100644 --- a/box_sdk_gen/managers/email_aliases.py +++ b/box_sdk_gen/managers/email_aliases.py @@ -30,6 +30,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class EmailAliasesManager: def __init__( @@ -58,9 +62,9 @@ def get_user_email_aliases( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/users/', to_string(user_id), '/email_aliases'] - ), + ''.join([ + 'https://api.box.com/2.0/users/', to_string(user_id), '/email_aliases' + ]), FetchOptions( method='GET', headers=headers_map, @@ -69,7 +73,7 @@ def get_user_email_aliases( network_session=self.network_session, ), ) - return deserialize(response.text, EmailAliases) + return deserialize(response.data, EmailAliases) def create_user_email_alias( self, @@ -97,20 +101,20 @@ def create_user_email_alias( request_body: Dict = {'email': email} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/users/', to_string(user_id), '/email_aliases'] - ), + ''.join([ + 'https://api.box.com/2.0/users/', to_string(user_id), '/email_aliases' + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, EmailAlias) + return deserialize(response.data, EmailAlias) def delete_user_email_alias_by_id( self, @@ -133,14 +137,12 @@ def delete_user_email_alias_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/users/', - to_string(user_id), - '/email_aliases/', - to_string(email_alias_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/users/', + to_string(user_id), + '/email_aliases/', + to_string(email_alias_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/events.py b/box_sdk_gen/managers/events.py index 2b77f97..fbfe037 100644 --- a/box_sdk_gen/managers/events.py +++ b/box_sdk_gen/managers/events.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetEventsStreamTypeArg(str, Enum): ALL = 'all' @@ -262,16 +266,14 @@ def get_events( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'stream_type': to_string(stream_type), - 'stream_position': to_string(stream_position), - 'limit': to_string(limit), - 'event_type': to_string(event_type), - 'created_after': to_string(created_after), - 'created_before': to_string(created_before), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'stream_type': to_string(stream_type), + 'stream_position': to_string(stream_position), + 'limit': to_string(limit), + 'event_type': to_string(event_type), + 'created_after': to_string(created_after), + 'created_before': to_string(created_before), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/events']), @@ -284,7 +286,7 @@ def get_events( network_session=self.network_session, ), ) - return deserialize(response.text, Events) + return deserialize(response.data, Events) def get_events_with_long_polling( self, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -379,4 +381,4 @@ def get_events_with_long_polling( network_session=self.network_session, ), ) - return deserialize(response.text, RealtimeServers) + return deserialize(response.data, RealtimeServers) diff --git a/box_sdk_gen/managers/file_classifications.py b/box_sdk_gen/managers/file_classifications.py index 3b00e69..7789346 100644 --- a/box_sdk_gen/managers/file_classifications.py +++ b/box_sdk_gen/managers/file_classifications.py @@ -34,6 +34,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgOpField( str, Enum @@ -118,13 +122,11 @@ def get_file_metadata_enterprise_security_classification_6_vm_vochw_u_wo( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='GET', headers=headers_map, @@ -133,7 +135,7 @@ def get_file_metadata_enterprise_security_classification_6_vm_vochw_u_wo( network_session=self.network_session, ), ) - return deserialize(response.text, Classification) + return deserialize(response.data, Classification) def create_file_metadata_enterprise_security_classification( self, @@ -179,24 +181,22 @@ def create_file_metadata_enterprise_security_classification( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Classification) + return deserialize(response.data, Classification) def update_file_metadata_enterprise_security_classification( self, @@ -234,24 +234,22 @@ def update_file_metadata_enterprise_security_classification( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Classification) + return deserialize(response.data, Classification) def delete_file_metadata_enterprise_security_classification( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -282,13 +280,11 @@ def delete_file_metadata_enterprise_security_classification( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/file_metadata.py b/box_sdk_gen/managers/file_metadata.py index 9d73921..ea1e4c2 100644 --- a/box_sdk_gen/managers/file_metadata.py +++ b/box_sdk_gen/managers/file_metadata.py @@ -38,6 +38,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class GetFileMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' @@ -146,9 +150,9 @@ def get_file_metadata( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/files/', to_string(file_id), '/metadata'] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/metadata' + ]), FetchOptions( method='GET', headers=headers_map, @@ -157,7 +161,7 @@ def get_file_metadata( network_session=self.network_session, ), ) - return deserialize(response.text, Metadatas) + return deserialize(response.data, Metadatas) def get_file_metadata_by_id( self, @@ -192,16 +196,14 @@ def get_file_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='GET', headers=headers_map, @@ -210,7 +212,7 @@ def get_file_metadata_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataFull) + return deserialize(response.data, MetadataFull) def create_file_metadata_by_id( self, @@ -254,27 +256,25 @@ def create_file_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Metadata) + return deserialize(response.data, Metadata) def update_file_metadata_by_id( self, @@ -324,27 +324,25 @@ def update_file_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Metadata) + return deserialize(response.data, Metadata) def delete_file_metadata_by_id( self, @@ -376,16 +374,14 @@ def delete_file_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/file_requests.py b/box_sdk_gen/managers/file_requests.py index 4b94948..58a124c 100644 --- a/box_sdk_gen/managers/file_requests.py +++ b/box_sdk_gen/managers/file_requests.py @@ -36,6 +36,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class UpdateFileRequestByIdStatusArg(str, Enum): ACTIVE = 'active' @@ -101,9 +105,9 @@ def get_file_request_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/file_requests/', to_string(file_request_id)] - ), + ''.join([ + 'https://api.box.com/2.0/file_requests/', to_string(file_request_id) + ]), FetchOptions( method='GET', headers=headers_map, @@ -112,7 +116,7 @@ def get_file_request_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, FileRequest) + return deserialize(response.data, FileRequest) def update_file_request_by_id( self, @@ -192,24 +196,24 @@ def update_file_request_by_id( 'is_description_required': is_description_required, 'expires_at': expires_at, } - headers_map: Dict[str, str] = prepare_params( - {'if-match': to_string(if_match), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), **extra_headers + }) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/file_requests/', to_string(file_request_id)] - ), + ''.join([ + 'https://api.box.com/2.0/file_requests/', to_string(file_request_id) + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileRequest) + return deserialize(response.data, FileRequest) def delete_file_request_by_id( self, @@ -233,9 +237,9 @@ def delete_file_request_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/file_requests/', to_string(file_request_id)] - ), + ''.join([ + 'https://api.box.com/2.0/file_requests/', to_string(file_request_id) + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -322,21 +326,19 @@ def create_file_request_copy( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/file_requests/', - to_string(file_request_id), - '/copy', - ] - ), + ''.join([ + 'https://api.box.com/2.0/file_requests/', + to_string(file_request_id), + '/copy', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileRequest) + return deserialize(response.data, FileRequest) diff --git a/box_sdk_gen/managers/file_version_legal_holds.py b/box_sdk_gen/managers/file_version_legal_holds.py index 8dbe772..c9733bb 100644 --- a/box_sdk_gen/managers/file_version_legal_holds.py +++ b/box_sdk_gen/managers/file_version_legal_holds.py @@ -28,6 +28,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class FileVersionLegalHoldsManager: def __init__( @@ -58,12 +62,10 @@ def get_file_version_legal_hold_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/file_version_legal_holds/', - to_string(file_version_legal_hold_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/file_version_legal_holds/', + to_string(file_version_legal_hold_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -72,7 +74,7 @@ def get_file_version_legal_hold_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionLegalHold) + return deserialize(response.data, FileVersionLegalHold) def get_file_version_legal_holds( self, @@ -139,13 +141,11 @@ def get_file_version_legal_holds( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'policy_id': to_string(policy_id), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'policy_id': to_string(policy_id), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/file_version_legal_holds']), @@ -158,4 +158,4 @@ def get_file_version_legal_holds( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionLegalHolds) + return deserialize(response.data, FileVersionLegalHolds) diff --git a/box_sdk_gen/managers/file_version_retentions.py b/box_sdk_gen/managers/file_version_retentions.py index d0c56ce..b2a9e96 100644 --- a/box_sdk_gen/managers/file_version_retentions.py +++ b/box_sdk_gen/managers/file_version_retentions.py @@ -24,12 +24,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetFileVersionRetentionsDispositionActionArg(str, Enum): PERMANENTLY_DELETE = 'permanently_delete' @@ -87,18 +91,16 @@ def get_file_version_retentions( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'file_id': to_string(file_id), - 'file_version_id': to_string(file_version_id), - 'policy_id': to_string(policy_id), - 'disposition_action': to_string(disposition_action), - 'disposition_before': to_string(disposition_before), - 'disposition_after': to_string(disposition_after), - 'limit': to_string(limit), - 'marker': to_string(marker), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'file_id': to_string(file_id), + 'file_version_id': to_string(file_version_id), + 'policy_id': to_string(policy_id), + 'disposition_action': to_string(disposition_action), + 'disposition_before': to_string(disposition_before), + 'disposition_after': to_string(disposition_after), + 'limit': to_string(limit), + 'marker': to_string(marker), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/file_version_retentions']), @@ -111,7 +113,7 @@ def get_file_version_retentions( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionRetentions) + return deserialize(response.data, FileVersionRetentions) def get_file_version_retention_by_id( self, @@ -130,12 +132,10 @@ def get_file_version_retention_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/file_version_retentions/', - to_string(file_version_retention_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/file_version_retentions/', + to_string(file_version_retention_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -144,4 +144,4 @@ def get_file_version_retention_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionRetention) + return deserialize(response.data, FileVersionRetention) diff --git a/box_sdk_gen/managers/file_versions.py b/box_sdk_gen/managers/file_versions.py index 1f4472c..8668f6a 100644 --- a/box_sdk_gen/managers/file_versions.py +++ b/box_sdk_gen/managers/file_versions.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class PromoteFileVersionTypeArg(str, Enum): FILE_VERSION = 'file_version' @@ -93,18 +97,16 @@ def get_file_versions( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'limit': to_string(limit), - 'offset': to_string(offset), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'limit': to_string(limit), + 'offset': to_string(offset), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/files/', to_string(file_id), '/versions'] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/versions' + ]), FetchOptions( method='GET', params=query_params_map, @@ -114,7 +116,7 @@ def get_file_versions( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersions) + return deserialize(response.data, FileVersions) def get_file_version_by_id( self, @@ -156,14 +158,12 @@ def get_file_version_by_id( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/versions/', - to_string(file_version_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/versions/', + to_string(file_version_id), + ]), FetchOptions( method='GET', params=query_params_map, @@ -173,7 +173,7 @@ def get_file_version_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionFull) + return deserialize(response.data, FileVersionFull) def update_file_version_by_id( self, @@ -215,25 +215,23 @@ def update_file_version_by_id( request_body: Dict = {'trashed_at': trashed_at} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/versions/', - to_string(file_version_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/versions/', + to_string(file_version_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionFull) + return deserialize(response.data, FileVersionFull) def delete_file_version_by_id( self, @@ -270,18 +268,16 @@ def delete_file_version_by_id( """ if extra_headers is None: extra_headers = {} - headers_map: Dict[str, str] = prepare_params( - {'if-match': to_string(if_match), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), **extra_headers + }) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/versions/', - to_string(file_version_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/versions/', + to_string(file_version_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -365,22 +361,20 @@ def promote_file_version( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/versions/current', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/versions/current', + ]), FetchOptions( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionFull) + return deserialize(response.data, FileVersionFull) diff --git a/box_sdk_gen/managers/file_watermarks.py b/box_sdk_gen/managers/file_watermarks.py index 83b6425..bfbc8d0 100644 --- a/box_sdk_gen/managers/file_watermarks.py +++ b/box_sdk_gen/managers/file_watermarks.py @@ -32,6 +32,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class UpdateFileWatermarkWatermarkArgImprintField(str, Enum): DEFAULT = 'default' @@ -77,9 +81,9 @@ def get_file_watermark( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/files/', to_string(file_id), '/watermark'] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/watermark' + ]), FetchOptions( method='GET', headers=headers_map, @@ -88,7 +92,7 @@ def get_file_watermark( network_session=self.network_session, ), ) - return deserialize(response.text, Watermark) + return deserialize(response.data, Watermark) def update_file_watermark( self, @@ -116,20 +120,20 @@ def update_file_watermark( request_body: Dict = {'watermark': watermark} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/files/', to_string(file_id), '/watermark'] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/watermark' + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Watermark) + return deserialize(response.data, Watermark) def delete_file_watermark( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -151,9 +155,9 @@ def delete_file_watermark( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/files/', to_string(file_id), '/watermark'] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/watermark' + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/files.py b/box_sdk_gen/managers/files.py index 4522f0e..4cc7efa 100644 --- a/box_sdk_gen/managers/files.py +++ b/box_sdk_gen/managers/files.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class UpdateFileByIdParentArg(BaseObject): def __init__(self, id: Optional[str] = None, **kwargs): @@ -265,14 +269,12 @@ def get_file_by_id( if extra_headers is None: extra_headers = {} query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - { - 'if-none-match': to_string(if_none_match), - 'boxapi': to_string(boxapi), - 'x-rep-hints': to_string(x_rep_hints), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-none-match': to_string(if_none_match), + 'boxapi': to_string(boxapi), + 'x-rep-hints': to_string(x_rep_hints), + **extra_headers, + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/files/', to_string(file_id)]), FetchOptions( @@ -284,7 +286,7 @@ def get_file_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def update_file_by_id( self, @@ -382,23 +384,23 @@ def update_file_by_id( 'tags': tags, } query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - {'if-match': to_string(if_match), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/files/', to_string(file_id)]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def delete_file_by_id( self, @@ -437,9 +439,9 @@ def delete_file_by_id( """ if extra_headers is None: extra_headers = {} - headers_map: Dict[str, str] = prepare_params( - {'if-match': to_string(if_match), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/files/', to_string(file_id)]), FetchOptions( @@ -505,14 +507,14 @@ def copy_file( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def get_file_thumbnail_by_id( self, @@ -568,24 +570,20 @@ def get_file_thumbnail_by_id( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'min_height': to_string(min_height), - 'min_width': to_string(min_width), - 'max_height': to_string(max_height), - 'max_width': to_string(max_width), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'min_height': to_string(min_height), + 'min_width': to_string(min_width), + 'max_height': to_string(max_height), + 'max_width': to_string(max_width), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/thumbnail.', - to_string(extension), - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/thumbnail.', + to_string(extension), + ]), FetchOptions( method='GET', params=query_params_map, diff --git a/box_sdk_gen/managers/folder_classifications.py b/box_sdk_gen/managers/folder_classifications.py index 5542356..0dd19ad 100644 --- a/box_sdk_gen/managers/folder_classifications.py +++ b/box_sdk_gen/managers/folder_classifications.py @@ -34,6 +34,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgOpField( str, Enum @@ -120,13 +124,11 @@ def get_folder_metadata_enterprise_security_classification_6_vm_vochw_u_wo( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='GET', headers=headers_map, @@ -135,7 +137,7 @@ def get_folder_metadata_enterprise_security_classification_6_vm_vochw_u_wo( network_session=self.network_session, ), ) - return deserialize(response.text, Classification) + return deserialize(response.data, Classification) def create_folder_metadata_enterprise_security_classification( self, @@ -183,24 +185,22 @@ def create_folder_metadata_enterprise_security_classification( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Classification) + return deserialize(response.data, Classification) def update_folder_metadata_enterprise_security_classification( self, @@ -240,24 +240,22 @@ def update_folder_metadata_enterprise_security_classification( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Classification) + return deserialize(response.data, Classification) def delete_folder_metadata_enterprise_security_classification( self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -290,13 +288,11 @@ def delete_folder_metadata_enterprise_security_classification( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/enterprise/securityClassification-6VMVochwUWo', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/enterprise/securityClassification-6VMVochwUWo', + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/folder_locks.py b/box_sdk_gen/managers/folder_locks.py index 1c964b7..d5ab917 100644 --- a/box_sdk_gen/managers/folder_locks.py +++ b/box_sdk_gen/managers/folder_locks.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateFolderLockLockedOperationsArg(BaseObject): def __init__(self, move: bool, delete: bool, **kwargs): @@ -94,9 +98,9 @@ def get_folder_locks( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'folder_id': to_string(folder_id)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'folder_id': to_string(folder_id) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/folder_locks']), @@ -109,7 +113,7 @@ def get_folder_locks( network_session=self.network_session, ), ) - return deserialize(response.text, FolderLocks) + return deserialize(response.data, FolderLocks) def create_folder_lock( self, @@ -146,14 +150,14 @@ def create_folder_lock( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderLock) + return deserialize(response.data, FolderLock) def delete_folder_lock_by_id( self, @@ -178,9 +182,9 @@ def delete_folder_lock_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folder_locks/', to_string(folder_lock_id)] - ), + ''.join([ + 'https://api.box.com/2.0/folder_locks/', to_string(folder_lock_id) + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/folder_metadata.py b/box_sdk_gen/managers/folder_metadata.py index 6422d87..9609e1d 100644 --- a/box_sdk_gen/managers/folder_metadata.py +++ b/box_sdk_gen/managers/folder_metadata.py @@ -38,6 +38,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class GetFolderMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' @@ -151,9 +155,9 @@ def get_folder_metadata( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/metadata'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/metadata' + ]), FetchOptions( method='GET', headers=headers_map, @@ -162,7 +166,7 @@ def get_folder_metadata( network_session=self.network_session, ), ) - return deserialize(response.text, Metadatas) + return deserialize(response.data, Metadatas) def get_folder_metadata_by_id( self, @@ -199,16 +203,14 @@ def get_folder_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='GET', headers=headers_map, @@ -217,7 +219,7 @@ def get_folder_metadata_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataFull) + return deserialize(response.data, MetadataFull) def create_folder_metadata_by_id( self, @@ -272,27 +274,25 @@ def create_folder_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Metadata) + return deserialize(response.data, Metadata) def update_folder_metadata_by_id( self, @@ -344,27 +344,25 @@ def update_folder_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Metadata) + return deserialize(response.data, Metadata) def delete_folder_metadata_by_id( self, @@ -398,16 +396,14 @@ def delete_folder_metadata_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/metadata/', - to_string(scope), - '/', - to_string(template_key), - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/metadata/', + to_string(scope), + '/', + to_string(template_key), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/folder_watermarks.py b/box_sdk_gen/managers/folder_watermarks.py index 6a8134f..7940ac9 100644 --- a/box_sdk_gen/managers/folder_watermarks.py +++ b/box_sdk_gen/managers/folder_watermarks.py @@ -32,6 +32,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class UpdateFolderWatermarkWatermarkArgImprintField(str, Enum): DEFAULT = 'default' @@ -81,9 +85,9 @@ def get_folder_watermark( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/watermark'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/watermark' + ]), FetchOptions( method='GET', headers=headers_map, @@ -92,7 +96,7 @@ def get_folder_watermark( network_session=self.network_session, ), ) - return deserialize(response.text, Watermark) + return deserialize(response.data, Watermark) def update_folder_watermark( self, @@ -122,20 +126,20 @@ def update_folder_watermark( request_body: Dict = {'watermark': watermark} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/watermark'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/watermark' + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Watermark) + return deserialize(response.data, Watermark) def delete_folder_watermark( self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -159,9 +163,9 @@ def delete_folder_watermark( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/watermark'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/watermark' + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/folders.py b/box_sdk_gen/managers/folders.py index 32fbb7b..601f1d3 100644 --- a/box_sdk_gen/managers/folders.py +++ b/box_sdk_gen/managers/folders.py @@ -30,12 +30,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetFolderByIdSortArg(str, Enum): ID = 'id' @@ -357,22 +361,18 @@ def get_folder_by_id( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'sort': to_string(sort), - 'direction': to_string(direction), - 'offset': to_string(offset), - 'limit': to_string(limit), - } - ) - headers_map: Dict[str, str] = prepare_params( - { - 'if-none-match': to_string(if_none_match), - 'boxapi': to_string(boxapi), - **extra_headers, - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'sort': to_string(sort), + 'direction': to_string(direction), + 'offset': to_string(offset), + 'limit': to_string(limit), + }) + headers_map: Dict[str, str] = prepare_params({ + 'if-none-match': to_string(if_none_match), + 'boxapi': to_string(boxapi), + **extra_headers, + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/folders/', to_string(folder_id)]), FetchOptions( @@ -384,7 +384,7 @@ def get_folder_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def update_folder_by_id( self, @@ -499,23 +499,23 @@ def update_folder_by_id( 'can_non_owners_view_collaborators': can_non_owners_view_collaborators, } query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - {'if-match': to_string(if_match), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/folders/', to_string(folder_id)]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def delete_folder_by_id( self, @@ -554,12 +554,12 @@ def delete_folder_by_id( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'recursive': to_string(recursive)} - ) - headers_map: Dict[str, str] = prepare_params( - {'if-match': to_string(if_match), **extra_headers} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'recursive': to_string(recursive) + }) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/folders/', to_string(folder_id)]), FetchOptions( @@ -678,24 +678,22 @@ def get_folder_items( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'usemarker': to_string(usemarker), - 'marker': to_string(marker), - 'offset': to_string(offset), - 'limit': to_string(limit), - 'sort': to_string(sort), - 'direction': to_string(direction), - } - ) - headers_map: Dict[str, str] = prepare_params( - {'boxapi': to_string(boxapi), **extra_headers} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'usemarker': to_string(usemarker), + 'marker': to_string(marker), + 'offset': to_string(offset), + 'limit': to_string(limit), + 'sort': to_string(sort), + 'direction': to_string(direction), + }) + headers_map: Dict[str, str] = prepare_params({ + 'boxapi': to_string(boxapi), **extra_headers + }) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/items'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/items' + ]), FetchOptions( method='GET', params=query_params_map, @@ -705,7 +703,7 @@ def get_folder_items( network_session=self.network_session, ), ) - return deserialize(response.text, Items) + return deserialize(response.data, Items) def create_folder( self, @@ -760,14 +758,14 @@ def create_folder( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def copy_folder( self, @@ -819,18 +817,18 @@ def copy_folder( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/copy'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/copy' + ]), FetchOptions( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) diff --git a/box_sdk_gen/managers/groups.py b/box_sdk_gen/managers/groups.py index e01f663..b57fd89 100644 --- a/box_sdk_gen/managers/groups.py +++ b/box_sdk_gen/managers/groups.py @@ -30,12 +30,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateGroupInvitabilityLevelArg(str, Enum): ADMINS_ONLY = 'admins_only' @@ -107,14 +111,12 @@ def get_groups( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'filter_term': to_string(filter_term), - 'fields': to_string(fields), - 'limit': to_string(limit), - 'offset': to_string(offset), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'filter_term': to_string(filter_term), + 'fields': to_string(fields), + 'limit': to_string(limit), + 'offset': to_string(offset), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/groups']), @@ -127,7 +129,7 @@ def get_groups( network_session=self.network_session, ), ) - return deserialize(response.text, Groups) + return deserialize(response.data, Groups) def create_group( self, @@ -213,14 +215,14 @@ def create_group( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Group) + return deserialize(response.data, Group) def get_group_by_id( self, @@ -266,7 +268,7 @@ def get_group_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, GroupFull) + return deserialize(response.data, GroupFull) def update_group_by_id( self, @@ -361,14 +363,14 @@ def update_group_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, GroupFull) + return deserialize(response.data, 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 0189949..f14c593 100644 --- a/box_sdk_gen/managers/integration_mappings.py +++ b/box_sdk_gen/managers/integration_mappings.py @@ -34,12 +34,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetIntegrationMappingSlackPartnerItemTypeArg(str, Enum): CHANNEL = 'channel' @@ -100,17 +104,15 @@ def get_integration_mapping_slack( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'marker': to_string(marker), - 'limit': to_string(limit), - 'partner_item_type': to_string(partner_item_type), - 'partner_item_id': to_string(partner_item_id), - 'box_item_id': to_string(box_item_id), - 'box_item_type': to_string(box_item_type), - 'is_manually_created': to_string(is_manually_created), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), + 'limit': to_string(limit), + 'partner_item_type': to_string(partner_item_type), + 'partner_item_id': to_string(partner_item_id), + 'box_item_id': to_string(box_item_id), + 'box_item_type': to_string(box_item_type), + 'is_manually_created': to_string(is_manually_created), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/integration_mappings/slack']), @@ -123,7 +125,7 @@ def get_integration_mapping_slack( network_session=self.network_session, ), ) - return deserialize(response.text, IntegrationMappings) + return deserialize(response.data, IntegrationMappings) def create_integration_mapping_slack( self, @@ -159,14 +161,14 @@ def create_integration_mapping_slack( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, IntegrationMapping) + return deserialize(response.data, IntegrationMapping) def update_integration_mapping_slack_by_id( self, @@ -197,23 +199,21 @@ def update_integration_mapping_slack_by_id( request_body: Dict = {'box_item': box_item, 'options': options} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/integration_mappings/slack/', - to_string(integration_mapping_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/integration_mappings/slack/', + to_string(integration_mapping_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, IntegrationMapping) + return deserialize(response.data, IntegrationMapping) def delete_integration_mapping_slack_by_id( self, @@ -238,12 +238,10 @@ def delete_integration_mapping_slack_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/integration_mappings/slack/', - to_string(integration_mapping_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/integration_mappings/slack/', + to_string(integration_mapping_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/invites.py b/box_sdk_gen/managers/invites.py index ea06fa3..0a7d30c 100644 --- a/box_sdk_gen/managers/invites.py +++ b/box_sdk_gen/managers/invites.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateInviteEnterpriseArg(BaseObject): def __init__(self, id: str, **kwargs): @@ -116,14 +120,14 @@ def create_invite( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Invite) + return deserialize(response.data, Invite) def get_invite_by_id( self, @@ -163,4 +167,4 @@ def get_invite_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, Invite) + return deserialize(response.data, Invite) diff --git a/box_sdk_gen/managers/legal_hold_policies.py b/box_sdk_gen/managers/legal_hold_policies.py index 6a59823..6a7e815 100644 --- a/box_sdk_gen/managers/legal_hold_policies.py +++ b/box_sdk_gen/managers/legal_hold_policies.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class LegalHoldPoliciesManager: def __init__( @@ -78,14 +82,12 @@ def get_legal_hold_policies( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'policy_name': to_string(policy_name), - 'fields': to_string(fields), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'policy_name': to_string(policy_name), + 'fields': to_string(fields), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/legal_hold_policies']), @@ -98,7 +100,7 @@ def get_legal_hold_policies( network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicies) + return deserialize(response.data, LegalHoldPolicies) def create_legal_hold_policy( self, @@ -159,14 +161,14 @@ def create_legal_hold_policy( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicy) + return deserialize(response.data, LegalHoldPolicy) def get_legal_hold_policy_by_id( self, @@ -185,12 +187,10 @@ def get_legal_hold_policy_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policies/', - to_string(legal_hold_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policies/', + to_string(legal_hold_policy_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -199,7 +199,7 @@ def get_legal_hold_policy_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicy) + return deserialize(response.data, LegalHoldPolicy) def update_legal_hold_policy_by_id( self, @@ -232,23 +232,21 @@ def update_legal_hold_policy_by_id( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policies/', - to_string(legal_hold_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policies/', + to_string(legal_hold_policy_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicy) + return deserialize(response.data, LegalHoldPolicy) def delete_legal_hold_policy_by_id( self, @@ -273,12 +271,10 @@ def delete_legal_hold_policy_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policies/', - to_string(legal_hold_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policies/', + to_string(legal_hold_policy_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/legal_hold_policy_assignments.py b/box_sdk_gen/managers/legal_hold_policy_assignments.py index 577f12c..027b258 100644 --- a/box_sdk_gen/managers/legal_hold_policy_assignments.py +++ b/box_sdk_gen/managers/legal_hold_policy_assignments.py @@ -32,12 +32,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetLegalHoldPolicyAssignmentsAssignToTypeArg(str, Enum): FILE = 'file' @@ -120,16 +124,14 @@ def get_legal_hold_policy_assignments( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'policy_id': to_string(policy_id), - 'assign_to_type': to_string(assign_to_type), - 'assign_to_id': to_string(assign_to_id), - 'marker': to_string(marker), - 'limit': to_string(limit), - 'fields': to_string(fields), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'policy_id': to_string(policy_id), + 'assign_to_type': to_string(assign_to_type), + 'assign_to_id': to_string(assign_to_id), + 'marker': to_string(marker), + 'limit': to_string(limit), + 'fields': to_string(fields), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/legal_hold_policy_assignments']), @@ -142,7 +144,7 @@ def get_legal_hold_policy_assignments( network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicyAssignments) + return deserialize(response.data, LegalHoldPolicyAssignments) def create_legal_hold_policy_assignment( self, @@ -168,14 +170,14 @@ def create_legal_hold_policy_assignment( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicyAssignment) + return deserialize(response.data, LegalHoldPolicyAssignment) def get_legal_hold_policy_assignment_by_id( self, @@ -194,12 +196,10 @@ def get_legal_hold_policy_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policy_assignments/', - to_string(legal_hold_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policy_assignments/', + to_string(legal_hold_policy_assignment_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -208,7 +208,7 @@ def get_legal_hold_policy_assignment_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, LegalHoldPolicyAssignment) + return deserialize(response.data, LegalHoldPolicyAssignment) def delete_legal_hold_policy_assignment_by_id( self, @@ -233,12 +233,10 @@ def delete_legal_hold_policy_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policy_assignments/', - to_string(legal_hold_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policy_assignments/', + to_string(legal_hold_policy_assignment_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -318,22 +316,18 @@ def get_legal_hold_policy_assignment_file_on_hold( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'marker': to_string(marker), - 'limit': to_string(limit), - 'fields': to_string(fields), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), + 'limit': to_string(limit), + 'fields': to_string(fields), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policy_assignments/', - to_string(legal_hold_policy_assignment_id), - '/files_on_hold', - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policy_assignments/', + to_string(legal_hold_policy_assignment_id), + '/files_on_hold', + ]), FetchOptions( method='GET', params=query_params_map, @@ -343,7 +337,7 @@ def get_legal_hold_policy_assignment_file_on_hold( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionLegalHolds) + return deserialize(response.data, FileVersionLegalHolds) def get_legal_hold_policy_assignment_file_version_on_hold( self, @@ -414,22 +408,18 @@ def get_legal_hold_policy_assignment_file_version_on_hold( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'marker': to_string(marker), - 'limit': to_string(limit), - 'fields': to_string(fields), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), + 'limit': to_string(limit), + 'fields': to_string(fields), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/legal_hold_policy_assignments/', - to_string(legal_hold_policy_assignment_id), - '/file_versions_on_hold', - ] - ), + ''.join([ + 'https://api.box.com/2.0/legal_hold_policy_assignments/', + to_string(legal_hold_policy_assignment_id), + '/file_versions_on_hold', + ]), FetchOptions( method='GET', params=query_params_map, @@ -439,4 +429,4 @@ def get_legal_hold_policy_assignment_file_version_on_hold( network_session=self.network_session, ), ) - return deserialize(response.text, FileVersionLegalHolds) + return deserialize(response.data, FileVersionLegalHolds) diff --git a/box_sdk_gen/managers/list_collaborations.py b/box_sdk_gen/managers/list_collaborations.py index b1a801a..ecaa86a 100644 --- a/box_sdk_gen/managers/list_collaborations.py +++ b/box_sdk_gen/managers/list_collaborations.py @@ -24,12 +24,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetCollaborationsStatusArg(str, Enum): PENDING = 'pending' @@ -88,22 +92,16 @@ def get_file_collaborations( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'limit': to_string(limit), - 'marker': to_string(marker), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'limit': to_string(limit), + 'marker': to_string(marker), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/collaborations', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '/collaborations' + ]), FetchOptions( method='GET', params=query_params_map, @@ -113,7 +111,7 @@ def get_file_collaborations( network_session=self.network_session, ), ) - return deserialize(response.text, Collaborations) + return deserialize(response.data, Collaborations) def get_folder_collaborations( self, @@ -154,13 +152,11 @@ def get_folder_collaborations( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '/collaborations', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '/collaborations', + ]), FetchOptions( method='GET', params=query_params_map, @@ -170,7 +166,7 @@ def get_folder_collaborations( network_session=self.network_session, ), ) - return deserialize(response.text, Collaborations) + return deserialize(response.data, Collaborations) def get_collaborations( self, @@ -205,14 +201,12 @@ def get_collaborations( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'status': to_string(status), - 'fields': to_string(fields), - 'offset': to_string(offset), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'status': to_string(status), + 'fields': to_string(fields), + 'offset': to_string(offset), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/collaborations']), @@ -225,7 +219,7 @@ def get_collaborations( network_session=self.network_session, ), ) - return deserialize(response.text, Collaborations) + return deserialize(response.data, Collaborations) def get_group_collaborations( self, @@ -260,18 +254,16 @@ def get_group_collaborations( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'limit': to_string(limit), 'offset': to_string(offset)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'limit': to_string(limit), 'offset': to_string(offset) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/groups/', - to_string(group_id), - '/collaborations', - ] - ), + ''.join([ + 'https://api.box.com/2.0/groups/', + to_string(group_id), + '/collaborations', + ]), FetchOptions( method='GET', params=query_params_map, @@ -281,4 +273,4 @@ def get_group_collaborations( network_session=self.network_session, ), ) - return deserialize(response.text, Collaborations) + return deserialize(response.data, Collaborations) diff --git a/box_sdk_gen/managers/memberships.py b/box_sdk_gen/managers/memberships.py index ee107f7..b142387 100644 --- a/box_sdk_gen/managers/memberships.py +++ b/box_sdk_gen/managers/memberships.py @@ -30,12 +30,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateGroupMembershipUserArg(BaseObject): def __init__(self, id: str, **kwargs): @@ -106,14 +110,14 @@ def get_user_memberships( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'limit': to_string(limit), 'offset': to_string(offset)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'limit': to_string(limit), 'offset': to_string(offset) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/users/', to_string(user_id), '/memberships'] - ), + ''.join([ + 'https://api.box.com/2.0/users/', to_string(user_id), '/memberships' + ]), FetchOptions( method='GET', params=query_params_map, @@ -123,7 +127,7 @@ def get_user_memberships( network_session=self.network_session, ), ) - return deserialize(response.text, GroupMemberships) + return deserialize(response.data, GroupMemberships) def get_group_memberships( self, @@ -155,14 +159,14 @@ def get_group_memberships( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'limit': to_string(limit), 'offset': to_string(offset)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'limit': to_string(limit), 'offset': to_string(offset) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/groups/', to_string(group_id), '/memberships'] - ), + ''.join([ + 'https://api.box.com/2.0/groups/', to_string(group_id), '/memberships' + ]), FetchOptions( method='GET', params=query_params_map, @@ -172,7 +176,7 @@ def get_group_memberships( network_session=self.network_session, ), ) - return deserialize(response.text, GroupMemberships) + return deserialize(response.data, GroupMemberships) def create_group_membership( self, @@ -231,14 +235,14 @@ def create_group_membership( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, GroupMembership) + return deserialize(response.data, GroupMembership) def get_group_membership_by_id( self, @@ -274,12 +278,10 @@ def get_group_membership_by_id( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/group_memberships/', - to_string(group_membership_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/group_memberships/', + to_string(group_membership_id), + ]), FetchOptions( method='GET', params=query_params_map, @@ -289,7 +291,7 @@ def get_group_membership_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, GroupMembership) + return deserialize(response.data, GroupMembership) def update_group_membership_by_id( self, @@ -342,24 +344,22 @@ def update_group_membership_by_id( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/group_memberships/', - to_string(group_membership_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/group_memberships/', + to_string(group_membership_id), + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, GroupMembership) + return deserialize(response.data, GroupMembership) def delete_group_membership_by_id( self, @@ -384,12 +384,10 @@ def delete_group_membership_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/group_memberships/', - to_string(group_membership_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/group_memberships/', + to_string(group_membership_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/metadata_cascade_policies.py b/box_sdk_gen/managers/metadata_cascade_policies.py index 5ec67ca..d1def66 100644 --- a/box_sdk_gen/managers/metadata_cascade_policies.py +++ b/box_sdk_gen/managers/metadata_cascade_policies.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateMetadataCascadePolicyScopeArg(str, Enum): GLOBAL = 'global' @@ -91,14 +95,12 @@ def get_metadata_cascade_policies( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'folder_id': to_string(folder_id), - 'owner_enterprise_id': to_string(owner_enterprise_id), - 'marker': to_string(marker), - 'offset': to_string(offset), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'folder_id': to_string(folder_id), + 'owner_enterprise_id': to_string(owner_enterprise_id), + 'marker': to_string(marker), + 'offset': to_string(offset), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/metadata_cascade_policies']), @@ -111,7 +113,7 @@ def get_metadata_cascade_policies( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataCascadePolicies) + return deserialize(response.data, MetadataCascadePolicies) def create_metadata_cascade_policy( self, @@ -170,14 +172,14 @@ def create_metadata_cascade_policy( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, MetadataCascadePolicy) + return deserialize(response.data, MetadataCascadePolicy) def get_metadata_cascade_policy_by_id( self, @@ -196,12 +198,10 @@ def get_metadata_cascade_policy_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_cascade_policies/', - to_string(metadata_cascade_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_cascade_policies/', + to_string(metadata_cascade_policy_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -210,7 +210,7 @@ def get_metadata_cascade_policy_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataCascadePolicy) + return deserialize(response.data, MetadataCascadePolicy) def delete_metadata_cascade_policy_by_id( self, @@ -229,12 +229,10 @@ def delete_metadata_cascade_policy_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_cascade_policies/', - to_string(metadata_cascade_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_cascade_policies/', + to_string(metadata_cascade_policy_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -280,17 +278,15 @@ def create_metadata_cascade_policy_apply( request_body: Dict = {'conflict_resolution': conflict_resolution} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_cascade_policies/', - to_string(metadata_cascade_policy_id), - '/apply', - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_cascade_policies/', + to_string(metadata_cascade_policy_id), + '/apply', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=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 3e16774..4fb6c8a 100644 --- a/box_sdk_gen/managers/metadata_templates.py +++ b/box_sdk_gen/managers/metadata_templates.py @@ -30,12 +30,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetMetadataTemplateSchemaScopeArg(str, Enum): GLOBAL = 'global' @@ -236,9 +240,9 @@ def get_metadata_templates( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'metadata_instance_id': to_string(metadata_instance_id)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'metadata_instance_id': to_string(metadata_instance_id) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/metadata_templates']), @@ -251,7 +255,7 @@ def get_metadata_templates( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplates) + return deserialize(response.data, MetadataTemplates) def get_metadata_template_schema( self, @@ -280,15 +284,13 @@ def get_metadata_template_schema( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/', - to_string(scope), - '/', - to_string(template_key), - '/schema', - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/', + to_string(scope), + '/', + to_string(template_key), + '/schema', + ]), FetchOptions( method='GET', headers=headers_map, @@ -297,7 +299,7 @@ def get_metadata_template_schema( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplate) + return deserialize(response.data, MetadataTemplate) def update_metadata_template_schema( self, @@ -335,26 +337,24 @@ def update_metadata_template_schema( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/', - to_string(scope), - '/', - to_string(template_key), - '/schema', - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/', + to_string(scope), + '/', + to_string(template_key), + '/schema', + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplate) + return deserialize(response.data, MetadataTemplate) def delete_metadata_template_schema( self, @@ -380,15 +380,13 @@ def delete_metadata_template_schema( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/metadata_templates/', - to_string(scope), - '/', - to_string(template_key), - '/schema', - ] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/', + to_string(scope), + '/', + to_string(template_key), + '/schema', + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -414,9 +412,9 @@ def get_metadata_template_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/metadata_templates/', to_string(template_id)] - ), + ''.join([ + 'https://api.box.com/2.0/metadata_templates/', to_string(template_id) + ]), FetchOptions( method='GET', headers=headers_map, @@ -425,7 +423,7 @@ def get_metadata_template_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplate) + return deserialize(response.data, MetadataTemplate) def get_metadata_template_global( self, @@ -449,9 +447,9 @@ def get_metadata_template_global( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/metadata_templates/global']), @@ -464,7 +462,7 @@ def get_metadata_template_global( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplates) + return deserialize(response.data, MetadataTemplates) def get_metadata_template_enterprise( self, @@ -488,9 +486,9 @@ def get_metadata_template_enterprise( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/metadata_templates/enterprise']), @@ -503,7 +501,7 @@ def get_metadata_template_enterprise( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplates) + return deserialize(response.data, MetadataTemplates) def create_metadata_template_schema( self, @@ -564,11 +562,11 @@ def create_metadata_template_schema( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, MetadataTemplate) + return deserialize(response.data, MetadataTemplate) diff --git a/box_sdk_gen/managers/recent_items.py b/box_sdk_gen/managers/recent_items.py index 5e95b29..5971f02 100644 --- a/box_sdk_gen/managers/recent_items.py +++ b/box_sdk_gen/managers/recent_items.py @@ -22,12 +22,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class RecentItemsManager: def __init__( @@ -73,13 +77,11 @@ def get_recent_items( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'limit': to_string(limit), - 'marker': to_string(marker), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'limit': to_string(limit), + 'marker': to_string(marker), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/recent_items']), @@ -92,4 +94,4 @@ def get_recent_items( network_session=self.network_session, ), ) - return deserialize(response.text, RecentItems) + return deserialize(response.data, RecentItems) diff --git a/box_sdk_gen/managers/retention_policies.py b/box_sdk_gen/managers/retention_policies.py index 8c6cc02..a8c1d61 100644 --- a/box_sdk_gen/managers/retention_policies.py +++ b/box_sdk_gen/managers/retention_policies.py @@ -32,12 +32,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetRetentionPoliciesPolicyTypeArg(str, Enum): FINITE = 'finite' @@ -106,16 +110,14 @@ def get_retention_policies( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'policy_name': to_string(policy_name), - 'policy_type': to_string(policy_type), - 'created_by_user_id': to_string(created_by_user_id), - 'fields': to_string(fields), - 'limit': to_string(limit), - 'marker': to_string(marker), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'policy_name': to_string(policy_name), + 'policy_type': to_string(policy_type), + 'created_by_user_id': to_string(created_by_user_id), + 'fields': to_string(fields), + 'limit': to_string(limit), + 'marker': to_string(marker), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/retention_policies']), @@ -128,7 +130,7 @@ def get_retention_policies( network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicies) + return deserialize(response.data, RetentionPolicies) def create_retention_policy( self, @@ -214,14 +216,14 @@ def create_retention_policy( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicy) + return deserialize(response.data, RetentionPolicy) def get_retention_policy_by_id( self, @@ -251,12 +253,10 @@ def get_retention_policy_by_id( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policies/', - to_string(retention_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policies/', + to_string(retention_policy_id), + ]), FetchOptions( method='GET', params=query_params_map, @@ -266,7 +266,7 @@ def get_retention_policy_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicy) + return deserialize(response.data, RetentionPolicy) def update_retention_policy_by_id( self, @@ -357,23 +357,21 @@ def update_retention_policy_by_id( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policies/', - to_string(retention_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policies/', + to_string(retention_policy_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicy) + return deserialize(response.data, RetentionPolicy) def delete_retention_policy_by_id( self, @@ -392,12 +390,10 @@ def delete_retention_policy_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policies/', - to_string(retention_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policies/', + to_string(retention_policy_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/retention_policy_assignments.py b/box_sdk_gen/managers/retention_policy_assignments.py index 3e3624a..51a77d8 100644 --- a/box_sdk_gen/managers/retention_policy_assignments.py +++ b/box_sdk_gen/managers/retention_policy_assignments.py @@ -32,12 +32,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetRetentionPolicyAssignmentsTypeArg(str, Enum): FOLDER = 'folder' @@ -134,23 +138,19 @@ def get_retention_policy_assignments( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'type': to_string(type), - 'fields': to_string(fields), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'type': to_string(type), + 'fields': to_string(fields), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policies/', - to_string(retention_policy_id), - '/assignments', - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policies/', + to_string(retention_policy_id), + '/assignments', + ]), FetchOptions( method='GET', params=query_params_map, @@ -160,7 +160,7 @@ def get_retention_policy_assignments( network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicyAssignments) + return deserialize(response.data, RetentionPolicyAssignments) def create_retention_policy_assignment( self, @@ -204,14 +204,14 @@ def create_retention_policy_assignment( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicyAssignment) + return deserialize(response.data, RetentionPolicyAssignment) def get_retention_policy_assignment_by_id( self, @@ -241,12 +241,10 @@ def get_retention_policy_assignment_by_id( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policy_assignments/', - to_string(retention_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policy_assignments/', + to_string(retention_policy_assignment_id), + ]), FetchOptions( method='GET', params=query_params_map, @@ -256,7 +254,7 @@ def get_retention_policy_assignment_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, RetentionPolicyAssignment) + return deserialize(response.data, RetentionPolicyAssignment) def delete_retention_policy_assignment_by_id( self, @@ -278,12 +276,10 @@ def delete_retention_policy_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policy_assignments/', - to_string(retention_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policy_assignments/', + to_string(retention_policy_assignment_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -317,18 +313,16 @@ def get_retention_policy_assignment_file_under_retention( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policy_assignments/', - to_string(retention_policy_assignment_id), - '/files_under_retention', - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policy_assignments/', + to_string(retention_policy_assignment_id), + '/files_under_retention', + ]), FetchOptions( method='GET', params=query_params_map, @@ -338,7 +332,7 @@ def get_retention_policy_assignment_file_under_retention( network_session=self.network_session, ), ) - return deserialize(response.text, FilesUnderRetention) + return deserialize(response.data, FilesUnderRetention) def get_retention_policy_assignment_file_version_under_retention( self, @@ -366,18 +360,16 @@ def get_retention_policy_assignment_file_version_under_retention( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/retention_policy_assignments/', - to_string(retention_policy_assignment_id), - '/file_versions_under_retention', - ] - ), + ''.join([ + 'https://api.box.com/2.0/retention_policy_assignments/', + to_string(retention_policy_assignment_id), + '/file_versions_under_retention', + ]), FetchOptions( method='GET', params=query_params_map, @@ -387,4 +379,4 @@ def get_retention_policy_assignment_file_version_under_retention( network_session=self.network_session, ), ) - return deserialize(response.text, FilesUnderRetention) + return deserialize(response.data, FilesUnderRetention) diff --git a/box_sdk_gen/managers/search.py b/box_sdk_gen/managers/search.py index 99eb2d2..a61e6d5 100644 --- a/box_sdk_gen/managers/search.py +++ b/box_sdk_gen/managers/search.py @@ -46,6 +46,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + +from box_sdk_gen.json import sd_to_json + class CreateMetadataQueryExecuteReadOrderByArgDirectionField(str, Enum): ASC = 'ASC' @@ -219,14 +223,14 @@ def create_metadata_query_execute_read( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, MetadataQueryResults) + return deserialize(response.data, MetadataQueryResults) def get_metadata_query_indices( self, @@ -245,9 +249,9 @@ def get_metadata_query_indices( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'scope': to_string(scope), 'template_key': to_string(template_key)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'scope': to_string(scope), 'template_key': to_string(template_key) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/metadata_query_indices']), @@ -260,7 +264,7 @@ def get_metadata_query_indices( network_session=self.network_session, ), ) - return deserialize(response.text, MetadataQueryIndices) + return deserialize(response.data, MetadataQueryIndices) def get_search( self, @@ -497,31 +501,29 @@ def get_search( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'query': to_string(query), - 'scope': to_string(scope), - 'file_extensions': to_string(file_extensions), - 'created_at_range': to_string(created_at_range), - 'updated_at_range': to_string(updated_at_range), - 'size_range': to_string(size_range), - 'owner_user_ids': to_string(owner_user_ids), - 'recent_updater_user_ids': to_string(recent_updater_user_ids), - 'ancestor_folder_ids': to_string(ancestor_folder_ids), - 'content_types': to_string(content_types), - 'type': to_string(type), - 'trash_content': to_string(trash_content), - 'mdfilters': to_string(mdfilters), - 'sort': to_string(sort), - 'direction': to_string(direction), - 'limit': to_string(limit), - 'include_recent_shared_links': to_string(include_recent_shared_links), - 'fields': to_string(fields), - 'offset': to_string(offset), - 'deleted_user_ids': to_string(deleted_user_ids), - 'deleted_at_range': to_string(deleted_at_range), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'query': to_string(query), + 'scope': to_string(scope), + 'file_extensions': to_string(file_extensions), + 'created_at_range': to_string(created_at_range), + 'updated_at_range': to_string(updated_at_range), + 'size_range': to_string(size_range), + 'owner_user_ids': to_string(owner_user_ids), + 'recent_updater_user_ids': to_string(recent_updater_user_ids), + 'ancestor_folder_ids': to_string(ancestor_folder_ids), + 'content_types': to_string(content_types), + 'type': to_string(type), + 'trash_content': to_string(trash_content), + 'mdfilters': to_string(mdfilters), + 'sort': to_string(sort), + 'direction': to_string(direction), + 'limit': to_string(limit), + 'include_recent_shared_links': to_string(include_recent_shared_links), + 'fields': to_string(fields), + 'offset': to_string(offset), + 'deleted_user_ids': to_string(deleted_user_ids), + 'deleted_at_range': to_string(deleted_at_range), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/search']), @@ -535,5 +537,5 @@ def get_search( ), ) return deserialize( - response.text, Union[SearchResults, SearchResultsWithSharedLinks] + response.data, Union[SearchResults, SearchResultsWithSharedLinks] ) diff --git a/box_sdk_gen/managers/session_termination.py b/box_sdk_gen/managers/session_termination.py index 23f898f..039c101 100644 --- a/box_sdk_gen/managers/session_termination.py +++ b/box_sdk_gen/managers/session_termination.py @@ -28,6 +28,8 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class SessionTerminationManager: def __init__( @@ -71,14 +73,14 @@ def create_user_terminate_session( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, SessionTerminationMessage) + return deserialize(response.data, SessionTerminationMessage) def create_group_terminate_session( self, @@ -110,11 +112,11 @@ def create_group_terminate_session( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, SessionTerminationMessage) + return deserialize(response.data, SessionTerminationMessage) diff --git a/box_sdk_gen/managers/shared_links_files.py b/box_sdk_gen/managers/shared_links_files.py index 1f0a468..3ee564d 100644 --- a/box_sdk_gen/managers/shared_links_files.py +++ b/box_sdk_gen/managers/shared_links_files.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class UpdateFileAddSharedLinkSharedLinkArgAccessField(str, Enum): OPEN = 'open' @@ -276,13 +280,11 @@ def get_shared_items( if extra_headers is None: extra_headers = {} query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - { - 'if-none-match': to_string(if_none_match), - 'boxapi': to_string(boxapi), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-none-match': to_string(if_none_match), + 'boxapi': to_string(boxapi), + **extra_headers, + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/shared_items']), FetchOptions( @@ -294,7 +296,7 @@ def get_shared_items( network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def get_file_get_shared_link( self, @@ -323,13 +325,9 @@ def get_file_get_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '#get_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '#get_shared_link' + ]), FetchOptions( method='GET', params=query_params_map, @@ -339,7 +337,7 @@ def get_file_get_shared_link( network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def update_file_add_shared_link( self, @@ -374,25 +372,21 @@ def update_file_add_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '#add_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', to_string(file_id), '#add_shared_link' + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def update_file_update_shared_link( self, @@ -425,25 +419,23 @@ def update_file_update_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '#update_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '#update_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) def update_file_remove_shared_link( self, @@ -477,22 +469,20 @@ def update_file_remove_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '#remove_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '#remove_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FileFull) + return deserialize(response.data, FileFull) diff --git a/box_sdk_gen/managers/shared_links_folders.py b/box_sdk_gen/managers/shared_links_folders.py index 5953983..cfa792a 100644 --- a/box_sdk_gen/managers/shared_links_folders.py +++ b/box_sdk_gen/managers/shared_links_folders.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class UpdateFolderAddSharedLinkSharedLinkArgAccessField(str, Enum): OPEN = 'open' @@ -264,13 +268,11 @@ def get_shared_item_folders( if extra_headers is None: extra_headers = {} query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - { - 'if-none-match': to_string(if_none_match), - 'boxapi': to_string(boxapi), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-none-match': to_string(if_none_match), + 'boxapi': to_string(boxapi), + **extra_headers, + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/shared_items#folders']), FetchOptions( @@ -282,7 +284,7 @@ def get_shared_item_folders( network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def get_folder_get_shared_link( self, @@ -313,13 +315,11 @@ def get_folder_get_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '#get_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '#get_shared_link', + ]), FetchOptions( method='GET', params=query_params_map, @@ -329,7 +329,7 @@ def get_folder_get_shared_link( network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def update_folder_add_shared_link( self, @@ -366,25 +366,23 @@ def update_folder_add_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '#add_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '#add_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def update_folder_update_shared_link( self, @@ -419,25 +417,23 @@ def update_folder_update_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '#update_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '#update_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) def update_folder_remove_shared_link( self, @@ -473,22 +469,20 @@ def update_folder_remove_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/folders/', - to_string(folder_id), - '#remove_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', + to_string(folder_id), + '#remove_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) diff --git a/box_sdk_gen/managers/shared_links_web_links.py b/box_sdk_gen/managers/shared_links_web_links.py index 9aa36b2..412945d 100644 --- a/box_sdk_gen/managers/shared_links_web_links.py +++ b/box_sdk_gen/managers/shared_links_web_links.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class UpdateWebLinkAddSharedLinkSharedLinkArgAccessField(str, Enum): OPEN = 'open' @@ -262,13 +266,11 @@ def get_shared_item_web_links( if extra_headers is None: extra_headers = {} query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - { - 'if-none-match': to_string(if_none_match), - 'boxapi': to_string(boxapi), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-none-match': to_string(if_none_match), + 'boxapi': to_string(boxapi), + **extra_headers, + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/shared_items#web_links']), FetchOptions( @@ -280,7 +282,7 @@ def get_shared_item_web_links( network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) def get_web_link_get_shared_link( self, @@ -304,13 +306,11 @@ def get_web_link_get_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/web_links/', - to_string(web_link_id), - '#get_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/web_links/', + to_string(web_link_id), + '#get_shared_link', + ]), FetchOptions( method='GET', params=query_params_map, @@ -320,7 +320,7 @@ def get_web_link_get_shared_link( network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) def update_web_link_add_shared_link( self, @@ -350,25 +350,23 @@ def update_web_link_add_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/web_links/', - to_string(web_link_id), - '#add_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/web_links/', + to_string(web_link_id), + '#add_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) def update_web_link_update_shared_link( self, @@ -396,25 +394,23 @@ def update_web_link_update_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/web_links/', - to_string(web_link_id), - '#update_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/web_links/', + to_string(web_link_id), + '#update_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) def update_web_link_remove_shared_link( self, @@ -443,22 +439,20 @@ def update_web_link_remove_shared_link( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/web_links/', - to_string(web_link_id), - '#remove_shared_link', - ] - ), + ''.join([ + 'https://api.box.com/2.0/web_links/', + to_string(web_link_id), + '#remove_shared_link', + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) diff --git a/box_sdk_gen/managers/shield_information_barrier_reports.py b/box_sdk_gen/managers/shield_information_barrier_reports.py index f51290d..0ca0024 100644 --- a/box_sdk_gen/managers/shield_information_barrier_reports.py +++ b/box_sdk_gen/managers/shield_information_barrier_reports.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class ShieldInformationBarrierReportsManager: def __init__( @@ -66,15 +70,11 @@ def get_shield_information_barrier_reports( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'shield_information_barrier_id': to_string( - shield_information_barrier_id - ), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'shield_information_barrier_id': to_string(shield_information_barrier_id), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/shield_information_barrier_reports']), @@ -87,7 +87,7 @@ def get_shield_information_barrier_reports( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierReports) + return deserialize(response.data, ShieldInformationBarrierReports) def create_shield_information_barrier_report( self, @@ -108,14 +108,14 @@ def create_shield_information_barrier_report( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierReport) + return deserialize(response.data, ShieldInformationBarrierReport) def get_shield_information_barrier_report_by_id( self, @@ -134,12 +134,10 @@ def get_shield_information_barrier_report_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_reports/', - to_string(shield_information_barrier_report_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_reports/', + to_string(shield_information_barrier_report_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -148,4 +146,4 @@ def get_shield_information_barrier_report_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierReport) + return deserialize(response.data, 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 3dc722e..a9e3f4c 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segment_members.py +++ b/box_sdk_gen/managers/shield_information_barrier_segment_members.py @@ -38,6 +38,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class CreateShieldInformationBarrierSegmentMemberTypeArg(str, Enum): SHIELD_INFORMATION_BARRIER_SEGMENT_MEMBER = ( @@ -103,12 +107,10 @@ def get_shield_information_barrier_segment_member_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segment_members/', - to_string(shield_information_barrier_segment_member_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_members/', + to_string(shield_information_barrier_segment_member_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -117,7 +119,7 @@ def get_shield_information_barrier_segment_member_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegmentMember) + return deserialize(response.data, ShieldInformationBarrierSegmentMember) def delete_shield_information_barrier_segment_member_by_id( self, @@ -139,12 +141,10 @@ def delete_shield_information_barrier_segment_member_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segment_members/', - to_string(shield_information_barrier_segment_member_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_members/', + to_string(shield_information_barrier_segment_member_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -180,20 +180,18 @@ def get_shield_information_barrier_segment_members( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'shield_information_barrier_segment_id': to_string( - shield_information_barrier_segment_id - ), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'shield_information_barrier_segment_id': to_string( + shield_information_barrier_segment_id + ), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/shield_information_barrier_segment_members'] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_members' + ]), FetchOptions( method='GET', params=query_params_map, @@ -203,7 +201,7 @@ def get_shield_information_barrier_segment_members( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegmentMembers) + return deserialize(response.data, ShieldInformationBarrierSegmentMembers) def create_shield_information_barrier_segment_member( self, @@ -235,17 +233,17 @@ def create_shield_information_barrier_segment_member( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/shield_information_barrier_segment_members'] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_members' + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegmentMember) + return deserialize(response.data, 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 bf6de87..5ff5b7c 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segment_restrictions.py +++ b/box_sdk_gen/managers/shield_information_barrier_segment_restrictions.py @@ -36,6 +36,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class CreateShieldInformationBarrierSegmentRestrictionTypeArg(str, Enum): SHIELD_INFORMATION_BARRIER_SEGMENT_RESTRICTION = ( @@ -129,12 +133,10 @@ def get_shield_information_barrier_segment_restriction_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions/', - to_string(shield_information_barrier_segment_restriction_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions/', + to_string(shield_information_barrier_segment_restriction_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -143,7 +145,7 @@ def get_shield_information_barrier_segment_restriction_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegmentRestriction) + return deserialize(response.data, ShieldInformationBarrierSegmentRestriction) def delete_shield_information_barrier_segment_restriction_by_id( self, @@ -165,12 +167,10 @@ def delete_shield_information_barrier_segment_restriction_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions/', - to_string(shield_information_barrier_segment_restriction_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions/', + to_string(shield_information_barrier_segment_restriction_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -206,22 +206,18 @@ def get_shield_information_barrier_segment_restrictions( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'shield_information_barrier_segment_id': to_string( - shield_information_barrier_segment_id - ), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'shield_information_barrier_segment_id': to_string( + shield_information_barrier_segment_id + ), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions' - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions' + ]), FetchOptions( method='GET', params=query_params_map, @@ -231,7 +227,7 @@ def get_shield_information_barrier_segment_restrictions( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegmentRestrictions) + return deserialize(response.data, ShieldInformationBarrierSegmentRestrictions) def create_shield_information_barrier_segment_restriction( self, @@ -268,19 +264,17 @@ def create_shield_information_barrier_segment_restriction( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions' - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segment_restrictions' + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegmentRestriction) + return deserialize(response.data, ShieldInformationBarrierSegmentRestriction) diff --git a/box_sdk_gen/managers/shield_information_barrier_segments.py b/box_sdk_gen/managers/shield_information_barrier_segments.py index 7d9ad4a..3458845 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segments.py +++ b/box_sdk_gen/managers/shield_information_barrier_segments.py @@ -32,6 +32,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class ShieldInformationBarrierSegmentsManager: def __init__( @@ -59,12 +63,10 @@ def get_shield_information_barrier_segment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segments/', - to_string(shield_information_barrier_segment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segments/', + to_string(shield_information_barrier_segment_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -73,7 +75,7 @@ def get_shield_information_barrier_segment_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegment) + return deserialize(response.data, ShieldInformationBarrierSegment) def update_shield_information_barrier_segment_by_id( self, @@ -100,23 +102,21 @@ def update_shield_information_barrier_segment_by_id( request_body: Dict = {'name': name, 'description': description} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segments/', - to_string(shield_information_barrier_segment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segments/', + to_string(shield_information_barrier_segment_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegment) + return deserialize(response.data, ShieldInformationBarrierSegment) def delete_shield_information_barrier_segment_by_id( self, @@ -138,12 +138,10 @@ def delete_shield_information_barrier_segment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barrier_segments/', - to_string(shield_information_barrier_segment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barrier_segments/', + to_string(shield_information_barrier_segment_id), + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -179,15 +177,11 @@ def get_shield_information_barrier_segments( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'shield_information_barrier_id': to_string( - shield_information_barrier_id - ), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'shield_information_barrier_id': to_string(shield_information_barrier_id), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/shield_information_barrier_segments']), @@ -200,7 +194,7 @@ def get_shield_information_barrier_segments( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegments) + return deserialize(response.data, ShieldInformationBarrierSegments) def create_shield_information_barrier_segment( self, @@ -231,11 +225,11 @@ def create_shield_information_barrier_segment( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrierSegment) + return deserialize(response.data, ShieldInformationBarrierSegment) diff --git a/box_sdk_gen/managers/shield_information_barriers.py b/box_sdk_gen/managers/shield_information_barriers.py index ffb9a83..0f49d4c 100644 --- a/box_sdk_gen/managers/shield_information_barriers.py +++ b/box_sdk_gen/managers/shield_information_barriers.py @@ -34,6 +34,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class CreateShieldInformationBarrierChangeStatusStatusArg(str, Enum): PENDING = 'pending' @@ -66,12 +70,10 @@ def get_shield_information_barrier_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/shield_information_barriers/', - to_string(shield_information_barrier_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barriers/', + to_string(shield_information_barrier_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -80,7 +82,7 @@ def get_shield_information_barrier_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrier) + return deserialize(response.data, ShieldInformationBarrier) def create_shield_information_barrier_change_status( self, @@ -102,20 +104,20 @@ def create_shield_information_barrier_change_status( request_body: Dict = {'id': id, 'status': status} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/shield_information_barriers/change_status'] - ), + ''.join([ + 'https://api.box.com/2.0/shield_information_barriers/change_status' + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrier) + return deserialize(response.data, ShieldInformationBarrier) def get_shield_information_barriers( self, @@ -138,9 +140,9 @@ def get_shield_information_barriers( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/shield_information_barriers']), @@ -153,7 +155,7 @@ def get_shield_information_barriers( network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarriers) + return deserialize(response.data, ShieldInformationBarriers) def create_shield_information_barrier( self, @@ -182,11 +184,11 @@ def create_shield_information_barrier( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ShieldInformationBarrier) + return deserialize(response.data, ShieldInformationBarrier) diff --git a/box_sdk_gen/managers/sign_requests.py b/box_sdk_gen/managers/sign_requests.py index 04e2fcb..e45766b 100644 --- a/box_sdk_gen/managers/sign_requests.py +++ b/box_sdk_gen/managers/sign_requests.py @@ -44,6 +44,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class CreateSignRequestSignatureColorArg(str, Enum): BLUE = 'blue' @@ -77,13 +81,11 @@ def cancel_sign_request( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/sign_requests/', - to_string(sign_request_id), - '/cancel', - ] - ), + ''.join([ + 'https://api.box.com/2.0/sign_requests/', + to_string(sign_request_id), + '/cancel', + ]), FetchOptions( method='POST', headers=headers_map, @@ -92,7 +94,7 @@ def cancel_sign_request( network_session=self.network_session, ), ) - return deserialize(response.text, SignRequest) + return deserialize(response.data, SignRequest) def resend_sign_request( self, @@ -111,13 +113,11 @@ def resend_sign_request( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/sign_requests/', - to_string(sign_request_id), - '/resend', - ] - ), + ''.join([ + 'https://api.box.com/2.0/sign_requests/', + to_string(sign_request_id), + '/resend', + ]), FetchOptions( method='POST', headers=headers_map, @@ -145,9 +145,9 @@ def get_sign_request_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/sign_requests/', to_string(sign_request_id)] - ), + ''.join([ + 'https://api.box.com/2.0/sign_requests/', to_string(sign_request_id) + ]), FetchOptions( method='GET', headers=headers_map, @@ -156,7 +156,7 @@ def get_sign_request_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, SignRequest) + return deserialize(response.data, SignRequest) def get_sign_requests( self, @@ -180,9 +180,9 @@ def get_sign_requests( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/sign_requests']), @@ -195,7 +195,7 @@ def get_sign_requests( network_session=self.network_session, ), ) - return deserialize(response.text, SignRequests) + return deserialize(response.data, SignRequests) def create_sign_request( self, @@ -287,11 +287,11 @@ def create_sign_request( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, SignRequest) + return deserialize(response.data, SignRequest) diff --git a/box_sdk_gen/managers/sign_templates.py b/box_sdk_gen/managers/sign_templates.py index 10c26e6..ee7a1d2 100644 --- a/box_sdk_gen/managers/sign_templates.py +++ b/box_sdk_gen/managers/sign_templates.py @@ -22,12 +22,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class SignTemplatesManager: def __init__( @@ -57,9 +61,9 @@ def get_sign_templates( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/sign_templates']), @@ -72,7 +76,7 @@ def get_sign_templates( network_session=self.network_session, ), ) - return deserialize(response.text, SignTemplates) + return deserialize(response.data, SignTemplates) def get_sign_template_by_id( self, template_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -89,9 +93,9 @@ def get_sign_template_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/sign_templates/', to_string(template_id)] - ), + ''.join([ + 'https://api.box.com/2.0/sign_templates/', to_string(template_id) + ]), FetchOptions( method='GET', headers=headers_map, @@ -100,4 +104,4 @@ def get_sign_template_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, SignTemplate) + return deserialize(response.data, SignTemplate) diff --git a/box_sdk_gen/managers/skills.py b/box_sdk_gen/managers/skills.py index 5a53112..7269371 100644 --- a/box_sdk_gen/managers/skills.py +++ b/box_sdk_gen/managers/skills.py @@ -44,6 +44,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArgOpField(str, Enum): REPLACE = 'replace' @@ -197,13 +201,11 @@ def get_file_metadata_global_box_skills_cards( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/global/boxSkillsCards', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/global/boxSkillsCards', + ]), FetchOptions( method='GET', headers=headers_map, @@ -212,7 +214,7 @@ def get_file_metadata_global_box_skills_cards( network_session=self.network_session, ), ) - return deserialize(response.text, SkillCardsMetadata) + return deserialize(response.data, SkillCardsMetadata) def create_file_metadata_global_box_skills_card( self, @@ -247,24 +249,22 @@ def create_file_metadata_global_box_skills_card( request_body: Dict = {'cards': cards} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/global/boxSkillsCards', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/global/boxSkillsCards', + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, SkillCardsMetadata) + return deserialize(response.data, SkillCardsMetadata) def update_file_metadata_global_box_skills_card( self, @@ -291,24 +291,22 @@ def update_file_metadata_global_box_skills_card( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/global/boxSkillsCards', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/global/boxSkillsCards', + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, SkillCardsMetadata) + return deserialize(response.data, SkillCardsMetadata) def delete_file_metadata_global_box_skills_card( self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -330,13 +328,11 @@ def delete_file_metadata_global_box_skills_card( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/files/', - to_string(file_id), - '/metadata/global/boxSkillsCards', - ] - ), + ''.join([ + 'https://api.box.com/2.0/files/', + to_string(file_id), + '/metadata/global/boxSkillsCards', + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -393,13 +389,13 @@ def update_skill_invocation_by_id( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/skill_invocations/', to_string(skill_id)] - ), + ''.join([ + 'https://api.box.com/2.0/skill_invocations/', to_string(skill_id) + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=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 7a883a4..843623e 100644 --- a/box_sdk_gen/managers/storage_policies.py +++ b/box_sdk_gen/managers/storage_policies.py @@ -24,12 +24,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class StoragePoliciesManager: def __init__( @@ -69,13 +73,11 @@ def get_storage_policies( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'marker': to_string(marker), - 'limit': to_string(limit), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'marker': to_string(marker), + 'limit': to_string(limit), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/storage_policies']), @@ -88,7 +90,7 @@ def get_storage_policies( network_session=self.network_session, ), ) - return deserialize(response.text, StoragePolicies) + return deserialize(response.data, StoragePolicies) def get_storage_policy_by_id( self, @@ -107,12 +109,10 @@ def get_storage_policy_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/storage_policies/', - to_string(storage_policy_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/storage_policies/', + to_string(storage_policy_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -121,4 +121,4 @@ def get_storage_policy_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, StoragePolicy) + return deserialize(response.data, StoragePolicy) diff --git a/box_sdk_gen/managers/storage_policy_assignments.py b/box_sdk_gen/managers/storage_policy_assignments.py index dbc8ff2..28b82f1 100644 --- a/box_sdk_gen/managers/storage_policy_assignments.py +++ b/box_sdk_gen/managers/storage_policy_assignments.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetStoragePolicyAssignmentsResolvedForTypeArg(str, Enum): USER = 'user' @@ -138,13 +142,11 @@ def get_storage_policy_assignments( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'marker': to_string(marker), - 'resolved_for_type': to_string(resolved_for_type), - 'resolved_for_id': to_string(resolved_for_id), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), + 'resolved_for_type': to_string(resolved_for_type), + 'resolved_for_id': to_string(resolved_for_id), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/storage_policy_assignments']), @@ -157,7 +159,7 @@ def get_storage_policy_assignments( network_session=self.network_session, ), ) - return deserialize(response.text, StoragePolicyAssignments) + return deserialize(response.data, StoragePolicyAssignments) def create_storage_policy_assignment( self, @@ -188,14 +190,14 @@ def create_storage_policy_assignment( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, StoragePolicyAssignment) + return deserialize(response.data, StoragePolicyAssignment) def get_storage_policy_assignment_by_id( self, @@ -214,12 +216,10 @@ def get_storage_policy_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/storage_policy_assignments/', - to_string(storage_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/storage_policy_assignments/', + to_string(storage_policy_assignment_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -228,7 +228,7 @@ def get_storage_policy_assignment_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, StoragePolicyAssignment) + return deserialize(response.data, StoragePolicyAssignment) def update_storage_policy_assignment_by_id( self, @@ -252,23 +252,21 @@ def update_storage_policy_assignment_by_id( request_body: Dict = {'storage_policy': storage_policy} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/storage_policy_assignments/', - to_string(storage_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/storage_policy_assignments/', + to_string(storage_policy_assignment_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, StoragePolicyAssignment) + return deserialize(response.data, StoragePolicyAssignment) def delete_storage_policy_assignment_by_id( self, @@ -302,12 +300,10 @@ def delete_storage_policy_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/storage_policy_assignments/', - to_string(storage_policy_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/storage_policy_assignments/', + to_string(storage_policy_assignment_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/task_assignments.py b/box_sdk_gen/managers/task_assignments.py index 50f8363..c952fe0 100644 --- a/box_sdk_gen/managers/task_assignments.py +++ b/box_sdk_gen/managers/task_assignments.py @@ -34,6 +34,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class CreateTaskAssignmentTaskArgTypeField(str, Enum): TASK = 'task' @@ -100,9 +104,9 @@ def get_task_assignments( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/tasks/', to_string(task_id), '/assignments'] - ), + ''.join([ + 'https://api.box.com/2.0/tasks/', to_string(task_id), '/assignments' + ]), FetchOptions( method='GET', headers=headers_map, @@ -111,7 +115,7 @@ def get_task_assignments( network_session=self.network_session, ), ) - return deserialize(response.text, TaskAssignments) + return deserialize(response.data, TaskAssignments) def create_task_assignment( self, @@ -143,14 +147,14 @@ def create_task_assignment( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TaskAssignment) + return deserialize(response.data, TaskAssignment) def get_task_assignment_by_id( self, @@ -169,12 +173,10 @@ def get_task_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/task_assignments/', - to_string(task_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/task_assignments/', + to_string(task_assignment_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -183,7 +185,7 @@ def get_task_assignment_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, TaskAssignment) + return deserialize(response.data, TaskAssignment) def update_task_assignment_by_id( self, @@ -216,23 +218,21 @@ def update_task_assignment_by_id( request_body: Dict = {'message': message, 'resolution_state': resolution_state} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/task_assignments/', - to_string(task_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/task_assignments/', + to_string(task_assignment_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TaskAssignment) + return deserialize(response.data, TaskAssignment) def delete_task_assignment_by_id( self, @@ -251,12 +251,10 @@ def delete_task_assignment_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/task_assignments/', - to_string(task_assignment_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/task_assignments/', + to_string(task_assignment_id), + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/tasks.py b/box_sdk_gen/managers/tasks.py index bb63b8c..9184c9f 100644 --- a/box_sdk_gen/managers/tasks.py +++ b/box_sdk_gen/managers/tasks.py @@ -34,6 +34,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import sd_to_json + +from box_sdk_gen.json import SerializedData + class CreateTaskItemArgTypeField(str, Enum): FILE = 'file' @@ -118,7 +122,7 @@ def get_file_tasks( network_session=self.network_session, ), ) - return deserialize(response.text, Tasks) + return deserialize(response.data, Tasks) def create_task( self, @@ -171,14 +175,14 @@ def create_task( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Task) + return deserialize(response.data, Task) def get_task_by_id( self, task_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -204,7 +208,7 @@ def get_task_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, Task) + return deserialize(response.data, Task) def update_task_by_id( self, @@ -256,14 +260,14 @@ def update_task_by_id( FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Task) + return deserialize(response.data, 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 9a9cb9a..8c310aa 100644 --- a/box_sdk_gen/managers/terms_of_service_user_statuses.py +++ b/box_sdk_gen/managers/terms_of_service_user_statuses.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateTermOfServiceUserStatusTosArgTypeField(str, Enum): TERMS_OF_SERVICE = 'terms_of_service' @@ -105,9 +109,9 @@ def get_term_of_service_user_statuses( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'tos_id': to_string(tos_id), 'user_id': to_string(user_id)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'tos_id': to_string(tos_id), 'user_id': to_string(user_id) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/terms_of_service_user_statuses']), @@ -120,7 +124,7 @@ def get_term_of_service_user_statuses( network_session=self.network_session, ), ) - return deserialize(response.text, TermsOfServiceUserStatuses) + return deserialize(response.data, TermsOfServiceUserStatuses) def create_term_of_service_user_status( self, @@ -149,14 +153,14 @@ def create_term_of_service_user_status( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TermsOfServiceUserStatus) + return deserialize(response.data, TermsOfServiceUserStatus) def update_term_of_service_user_status_by_id( self, @@ -179,20 +183,18 @@ def update_term_of_service_user_status_by_id( request_body: Dict = {'is_accepted': is_accepted} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/terms_of_service_user_statuses/', - to_string(terms_of_service_user_status_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/terms_of_service_user_statuses/', + to_string(terms_of_service_user_status_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TermsOfServiceUserStatus) + return deserialize(response.data, TermsOfServiceUserStatus) diff --git a/box_sdk_gen/managers/terms_of_services.py b/box_sdk_gen/managers/terms_of_services.py index 9de94db..dbc40a2 100644 --- a/box_sdk_gen/managers/terms_of_services.py +++ b/box_sdk_gen/managers/terms_of_services.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetTermOfServicesTosTypeArg(str, Enum): EXTERNAL = 'external' @@ -81,9 +85,9 @@ def get_term_of_services( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'tos_type': to_string(tos_type)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'tos_type': to_string(tos_type) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/terms_of_services']), @@ -96,7 +100,7 @@ def get_term_of_services( network_session=self.network_session, ), ) - return deserialize(response.text, TermsOfServices) + return deserialize(response.data, TermsOfServices) def create_term_of_service( self, @@ -130,14 +134,14 @@ def create_term_of_service( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Task) + return deserialize(response.data, Task) def get_term_of_service_by_id( self, @@ -156,12 +160,10 @@ def get_term_of_service_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/terms_of_services/', - to_string(terms_of_service_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/terms_of_services/', + to_string(terms_of_service_id), + ]), FetchOptions( method='GET', headers=headers_map, @@ -170,7 +172,7 @@ def get_term_of_service_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, TermsOfService) + return deserialize(response.data, TermsOfService) def update_term_of_service_by_id( self, @@ -197,20 +199,18 @@ def update_term_of_service_by_id( request_body: Dict = {'status': status, 'text': text} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - [ - 'https://api.box.com/2.0/terms_of_services/', - to_string(terms_of_service_id), - ] - ), + ''.join([ + 'https://api.box.com/2.0/terms_of_services/', + to_string(terms_of_service_id), + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TermsOfService) + return deserialize(response.data, TermsOfService) diff --git a/box_sdk_gen/managers/transfer.py b/box_sdk_gen/managers/transfer.py index f208f98..cf44f43 100644 --- a/box_sdk_gen/managers/transfer.py +++ b/box_sdk_gen/managers/transfer.py @@ -26,12 +26,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class TransferOwnedFolderOwnedByArg(BaseObject): def __init__(self, id: str, **kwargs): @@ -152,23 +156,23 @@ def transfer_owned_folder( if extra_headers is None: extra_headers = {} request_body: Dict = {'owned_by': owned_by} - query_params_map: Dict[str, str] = prepare_params( - {'fields': to_string(fields), 'notify': to_string(notify)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), 'notify': to_string(notify) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/users/', to_string(user_id), '/folders/0'] - ), + ''.join([ + 'https://api.box.com/2.0/users/', to_string(user_id), '/folders/0' + ]), FetchOptions( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, FolderFull) + return deserialize(response.data, FolderFull) diff --git a/box_sdk_gen/managers/trashed_files.py b/box_sdk_gen/managers/trashed_files.py index f34871e..f5b854e 100644 --- a/box_sdk_gen/managers/trashed_files.py +++ b/box_sdk_gen/managers/trashed_files.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class RestoreFileFromTrashParentArg(BaseObject): def __init__(self, id: Optional[str] = None, **kwargs): @@ -103,14 +107,14 @@ def restore_file_from_trash( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TrashFileRestored) + return deserialize(response.data, TrashFileRestored) def get_file_trash( self, @@ -179,7 +183,7 @@ def get_file_trash( network_session=self.network_session, ), ) - return deserialize(response.text, TrashFile) + return deserialize(response.data, 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 0640cfa..e8d4168 100644 --- a/box_sdk_gen/managers/trashed_folders.py +++ b/box_sdk_gen/managers/trashed_folders.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class RestoreFolderFromTrashParentArg(BaseObject): def __init__(self, id: Optional[str] = None, **kwargs): @@ -123,14 +127,14 @@ def restore_folder_from_trash( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TrashFolderRestored) + return deserialize(response.data, TrashFolderRestored) def get_folder_trash( self, @@ -191,9 +195,9 @@ def get_folder_trash( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/trash'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/trash' + ]), FetchOptions( method='GET', params=query_params_map, @@ -203,7 +207,7 @@ def get_folder_trash( network_session=self.network_session, ), ) - return deserialize(response.text, TrashFolder) + return deserialize(response.data, TrashFolder) def delete_folder_trash( self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -230,9 +234,9 @@ def delete_folder_trash( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/folders/', to_string(folder_id), '/trash'] - ), + ''.join([ + 'https://api.box.com/2.0/folders/', to_string(folder_id), '/trash' + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/trashed_items.py b/box_sdk_gen/managers/trashed_items.py index 7dc40df..cd15e48 100644 --- a/box_sdk_gen/managers/trashed_items.py +++ b/box_sdk_gen/managers/trashed_items.py @@ -24,12 +24,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetFolderTrashItemsDirectionArg(str, Enum): ASC = 'ASC' @@ -124,17 +128,15 @@ def get_folder_trash_items( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'fields': to_string(fields), - 'limit': to_string(limit), - 'offset': to_string(offset), - 'usemarker': to_string(usemarker), - 'marker': to_string(marker), - 'direction': to_string(direction), - 'sort': to_string(sort), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), + 'limit': to_string(limit), + 'offset': to_string(offset), + 'usemarker': to_string(usemarker), + 'marker': to_string(marker), + 'direction': to_string(direction), + 'sort': to_string(sort), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/folders/trash/items']), @@ -147,4 +149,4 @@ def get_folder_trash_items( network_session=self.network_session, ), ) - return deserialize(response.text, Items) + return deserialize(response.data, Items) diff --git a/box_sdk_gen/managers/trashed_web_links.py b/box_sdk_gen/managers/trashed_web_links.py index a99cb31..c9e530d 100644 --- a/box_sdk_gen/managers/trashed_web_links.py +++ b/box_sdk_gen/managers/trashed_web_links.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class RestoreWeblinkFromTrashParentArg(BaseObject): def __init__(self, id: Optional[str] = None, **kwargs): @@ -98,14 +102,14 @@ def restore_weblink_from_trash( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, TrashWebLinkRestored) + return deserialize(response.data, TrashWebLinkRestored) def get_web_link_trash( self, @@ -135,9 +139,9 @@ def get_web_link_trash( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/web_links/', to_string(web_link_id), '/trash'] - ), + ''.join([ + 'https://api.box.com/2.0/web_links/', to_string(web_link_id), '/trash' + ]), FetchOptions( method='GET', params=query_params_map, @@ -147,7 +151,7 @@ def get_web_link_trash( network_session=self.network_session, ), ) - return deserialize(response.text, TrashWebLink) + return deserialize(response.data, TrashWebLink) def delete_web_link_trash( self, web_link_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -167,9 +171,9 @@ def delete_web_link_trash( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/web_links/', to_string(web_link_id), '/trash'] - ), + ''.join([ + 'https://api.box.com/2.0/web_links/', to_string(web_link_id), '/trash' + ]), FetchOptions( method='DELETE', headers=headers_map, diff --git a/box_sdk_gen/managers/uploads.py b/box_sdk_gen/managers/uploads.py index 0b705e4..26bd4ac 100644 --- a/box_sdk_gen/managers/uploads.py +++ b/box_sdk_gen/managers/uploads.py @@ -30,6 +30,8 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions @@ -38,6 +40,8 @@ from box_sdk_gen.fetch import MultipartItem +from box_sdk_gen.json import SerializedData + class UploadFileVersionAttributesArg(BaseObject): def __init__(self, name: str, content_modified_at: Optional[str] = None, **kwargs): @@ -201,21 +205,15 @@ def upload_file_version( 'file_content_type': file_content_type, } query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - { - 'if-match': to_string(if_match), - 'content-md5': to_string(content_md_5), - **extra_headers, - } - ) + headers_map: Dict[str, str] = prepare_params({ + 'if-match': to_string(if_match), + 'content-md5': to_string(content_md_5), + **extra_headers, + }) response: FetchResponse = fetch( - ''.join( - [ - 'https://upload.box.com/api/2.0/files/', - to_string(file_id), - '/content', - ] - ), + ''.join([ + 'https://upload.box.com/api/2.0/files/', to_string(file_id), '/content' + ]), FetchOptions( method='POST', params=query_params_map, @@ -223,7 +221,7 @@ def upload_file_version( multipart_data=[ MultipartItem( part_name='attributes', - body=serialize(request_body['attributes']), + data=serialize(request_body['attributes']), ), MultipartItem( part_name='file', @@ -238,7 +236,7 @@ def upload_file_version( network_session=self.network_session, ), ) - return deserialize(response.text, Files) + return deserialize(response.data, Files) def upload_file( self, @@ -312,9 +310,9 @@ def upload_file( 'file_content_type': file_content_type, } query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) - headers_map: Dict[str, str] = prepare_params( - {'content-md5': to_string(content_md_5), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'content-md5': to_string(content_md_5), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://upload.box.com/api/2.0/files/content']), FetchOptions( @@ -324,7 +322,7 @@ def upload_file( multipart_data=[ MultipartItem( part_name='attributes', - body=serialize(request_body['attributes']), + data=serialize(request_body['attributes']), ), MultipartItem( part_name='file', @@ -339,7 +337,7 @@ def upload_file( network_session=self.network_session, ), ) - return deserialize(response.text, Files) + return deserialize(response.data, Files) def preflight_file_upload( self, @@ -369,11 +367,11 @@ def preflight_file_upload( FetchOptions( method='OPTIONS', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, UploadUrl) + return deserialize(response.data, UploadUrl) diff --git a/box_sdk_gen/managers/user_collaborations.py b/box_sdk_gen/managers/user_collaborations.py index 80af618..f431170 100644 --- a/box_sdk_gen/managers/user_collaborations.py +++ b/box_sdk_gen/managers/user_collaborations.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class UpdateCollaborationByIdRoleArg(str, Enum): EDITOR = 'editor' @@ -153,9 +157,9 @@ def get_collaboration_by_id( query_params_map: Dict[str, str] = prepare_params({'fields': to_string(fields)}) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/collaborations/', to_string(collaboration_id)] - ), + ''.join([ + 'https://api.box.com/2.0/collaborations/', to_string(collaboration_id) + ]), FetchOptions( method='GET', params=query_params_map, @@ -165,7 +169,7 @@ def get_collaboration_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, Collaboration) + return deserialize(response.data, Collaboration) def update_collaboration_by_id( self, @@ -229,20 +233,20 @@ def update_collaboration_by_id( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/collaborations/', to_string(collaboration_id)] - ), + ''.join([ + 'https://api.box.com/2.0/collaborations/', to_string(collaboration_id) + ]), FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Collaboration) + return deserialize(response.data, Collaboration) def delete_collaboration_by_id( self, @@ -261,9 +265,9 @@ def delete_collaboration_by_id( extra_headers = {} headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/collaborations/', to_string(collaboration_id)] - ), + ''.join([ + 'https://api.box.com/2.0/collaborations/', to_string(collaboration_id) + ]), FetchOptions( method='DELETE', headers=headers_map, @@ -375,9 +379,9 @@ def create_collaboration( 'can_view_path': can_view_path, 'expires_at': expires_at, } - query_params_map: Dict[str, str] = prepare_params( - {'fields': to_string(fields), 'notify': to_string(notify)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'fields': to_string(fields), 'notify': to_string(notify) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/collaborations']), @@ -385,11 +389,11 @@ def create_collaboration( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Collaboration) + return deserialize(response.data, Collaboration) diff --git a/box_sdk_gen/managers/users.py b/box_sdk_gen/managers/users.py index 034e8c5..1688f28 100644 --- a/box_sdk_gen/managers/users.py +++ b/box_sdk_gen/managers/users.py @@ -34,12 +34,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class GetUsersUserTypeArg(str, Enum): ALL = 'all' @@ -173,18 +177,16 @@ def get_users( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'filter_term': to_string(filter_term), - 'user_type': to_string(user_type), - 'external_app_user_id': to_string(external_app_user_id), - 'fields': to_string(fields), - 'offset': to_string(offset), - 'limit': to_string(limit), - 'usemarker': to_string(usemarker), - 'marker': to_string(marker), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'filter_term': to_string(filter_term), + 'user_type': to_string(user_type), + 'external_app_user_id': to_string(external_app_user_id), + 'fields': to_string(fields), + 'offset': to_string(offset), + 'limit': to_string(limit), + 'usemarker': to_string(usemarker), + 'marker': to_string(marker), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/users']), @@ -197,7 +199,7 @@ def get_users( network_session=self.network_session, ), ) - return deserialize(response.text, Users) + return deserialize(response.data, Users) def create_user( self, @@ -319,14 +321,14 @@ def create_user( method='POST', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, User) + return deserialize(response.data, User) def get_user_me( self, @@ -380,7 +382,7 @@ def get_user_me( network_session=self.network_session, ), ) - return deserialize(response.text, UserFull) + return deserialize(response.data, UserFull) def get_user_by_id( self, @@ -444,7 +446,7 @@ def get_user_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, UserFull) + return deserialize(response.data, UserFull) def update_user_by_id( self, @@ -590,14 +592,14 @@ def update_user_by_id( method='PUT', params=query_params_map, headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, UserFull) + return deserialize(response.data, UserFull) def delete_user_by_id( self, @@ -631,9 +633,9 @@ def delete_user_by_id( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'notify': to_string(notify), 'force': to_string(force)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'notify': to_string(notify), 'force': to_string(force) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/users/', to_string(user_id)]), diff --git a/box_sdk_gen/managers/web_links.py b/box_sdk_gen/managers/web_links.py index 4f7a467..22771b1 100644 --- a/box_sdk_gen/managers/web_links.py +++ b/box_sdk_gen/managers/web_links.py @@ -32,6 +32,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + +from box_sdk_gen.json import sd_to_json + class CreateWebLinkParentArg(BaseObject): def __init__(self, id: str, **kwargs): @@ -151,14 +155,14 @@ def create_web_link( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) def get_web_link_by_id( self, @@ -184,9 +188,9 @@ def get_web_link_by_id( """ if extra_headers is None: extra_headers = {} - headers_map: Dict[str, str] = prepare_params( - {'boxapi': to_string(boxapi), **extra_headers} - ) + headers_map: Dict[str, str] = prepare_params({ + 'boxapi': to_string(boxapi), **extra_headers + }) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/web_links/', to_string(web_link_id)]), FetchOptions( @@ -197,7 +201,7 @@ def get_web_link_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, WebLink) def update_web_link_by_id( self, @@ -241,14 +245,14 @@ def update_web_link_by_id( FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, WebLink) + return deserialize(response.data, 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 1f789d8..06587d9 100644 --- a/box_sdk_gen/managers/webhooks.py +++ b/box_sdk_gen/managers/webhooks.py @@ -30,12 +30,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateWebhookTargetArgTypeField(str, Enum): FILE = 'file' @@ -209,9 +213,9 @@ def get_webhooks( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - {'marker': to_string(marker), 'limit': to_string(limit)} - ) + query_params_map: Dict[str, str] = prepare_params({ + 'marker': to_string(marker), 'limit': to_string(limit) + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/webhooks']), @@ -224,7 +228,7 @@ def get_webhooks( network_session=self.network_session, ), ) - return deserialize(response.text, Webhooks) + return deserialize(response.data, Webhooks) def create_webhook( self, @@ -258,14 +262,14 @@ def create_webhook( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Webhook) + return deserialize(response.data, Webhook) def get_webhook_by_id( self, webhook_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -291,7 +295,7 @@ def get_webhook_by_id( network_session=self.network_session, ), ) - return deserialize(response.text, Webhook) + return deserialize(response.data, Webhook) def update_webhook_by_id( self, @@ -329,14 +333,14 @@ def update_webhook_by_id( FetchOptions( method='PUT', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, Webhook) + return deserialize(response.data, 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 539a838..88a6283 100644 --- a/box_sdk_gen/managers/workflows.py +++ b/box_sdk_gen/managers/workflows.py @@ -28,12 +28,16 @@ from box_sdk_gen.utils import ByteStream +from box_sdk_gen.json import sd_to_json + from box_sdk_gen.fetch import fetch from box_sdk_gen.fetch import FetchOptions from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + class CreateWorkflowStartTypeArg(str, Enum): WORKFLOW_PARAMETERS = 'workflow_parameters' @@ -174,14 +178,12 @@ def get_workflows( """ if extra_headers is None: extra_headers = {} - query_params_map: Dict[str, str] = prepare_params( - { - 'folder_id': to_string(folder_id), - 'trigger_type': to_string(trigger_type), - 'limit': to_string(limit), - 'marker': to_string(marker), - } - ) + query_params_map: Dict[str, str] = prepare_params({ + 'folder_id': to_string(folder_id), + 'trigger_type': to_string(trigger_type), + 'limit': to_string(limit), + 'marker': to_string(marker), + }) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( ''.join(['https://api.box.com/2.0/workflows']), @@ -194,7 +196,7 @@ def get_workflows( network_session=self.network_session, ), ) - return deserialize(response.text, Workflows) + return deserialize(response.data, Workflows) def create_workflow_start( self, @@ -242,13 +244,13 @@ def create_workflow_start( } headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch( - ''.join( - ['https://api.box.com/2.0/workflows/', to_string(workflow_id), '/start'] - ), + ''.join([ + 'https://api.box.com/2.0/workflows/', to_string(workflow_id), '/start' + ]), FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=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 5299736..0bca9a5 100644 --- a/box_sdk_gen/managers/zip_downloads.py +++ b/box_sdk_gen/managers/zip_downloads.py @@ -36,6 +36,10 @@ from box_sdk_gen.fetch import FetchResponse +from box_sdk_gen.json import SerializedData + +from box_sdk_gen.json import sd_to_json + class CreateZipDownloadItemsArgTypeField(str, Enum): FILE = 'file' @@ -149,14 +153,14 @@ def create_zip_download( FetchOptions( method='POST', headers=headers_map, - body=serialize(request_body), + data=serialize(request_body), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session, ), ) - return deserialize(response.text, ZipDownload) + return deserialize(response.data, ZipDownload) def get_zip_download_content( self, @@ -267,7 +271,7 @@ def get_zip_download_status( network_session=self.network_session, ), ) - return deserialize(response.text, ZipDownloadStatus) + return deserialize(response.data, ZipDownloadStatus) def download_zip( self, diff --git a/box_sdk_gen/network.py b/box_sdk_gen/network.py index 348e692..f5ccfd5 100644 --- a/box_sdk_gen/network.py +++ b/box_sdk_gen/network.py @@ -1,8 +1,23 @@ import requests +from typing import Dict class NetworkSession: MAX_ATTEMPTS = 5 - def __init__(self): + def __init__(self, additional_headers: Dict[str, str] = None): + if additional_headers is None: + additional_headers = {} self.requests_session = requests.Session() + self.additional_headers = additional_headers + + def with_additional_headers( + self, additional_headers: Dict[str, str] = None + ) -> 'NetworkSession': + """ + Generate a fresh network session by duplicating the existing configuration and network parameters, + while also including additional headers to be attached to every API call. + :param additional_headers: Dict of headers, which are appended to each API request + :return: a new instance of NetworkSession + """ + return NetworkSession({**self.additional_headers, **additional_headers}) diff --git a/box_sdk_gen/oauth.py b/box_sdk_gen/oauth.py index a7d7645..be11d90 100644 --- a/box_sdk_gen/oauth.py +++ b/box_sdk_gen/oauth.py @@ -1,4 +1,3 @@ -import json from urllib.parse import urlencode, urlunsplit from typing import Optional @@ -8,6 +7,7 @@ from .fetch import fetch, FetchResponse, FetchOptions from .network import NetworkSession from .schemas import AccessToken +from .json import json_to_serialized_data class OAuthConfig: @@ -182,10 +182,10 @@ def _send_token_request( 'https://api.box.com/oauth2/token', FetchOptions( method='POST', - body=urlencode(request_body.to_dict()), - headers={'content-type': 'application/x-www-form-urlencoded'}, + data=request_body.to_dict(), + content_type='application/x-www-form-urlencoded', network_session=network_session, ), ) - return AccessToken.from_dict(json.loads(response.text)) + return AccessToken.from_dict(json_to_serialized_data(response.text)) diff --git a/box_sdk_gen/serialization.py b/box_sdk_gen/serialization.py index 21c2474..b16328e 100644 --- a/box_sdk_gen/serialization.py +++ b/box_sdk_gen/serialization.py @@ -2,9 +2,10 @@ from typing import get_origin, Union, Type from .base_object import BaseObject +from .json import SerializedData -def serialize(obj: Union[BaseObject, dict, list]): +def serialize(obj: Union[BaseObject, dict, list]) -> SerializedData: if isinstance(obj, dict): obj = BaseObject(**obj).to_dict() if isinstance(obj, BaseObject): @@ -14,12 +15,10 @@ def serialize(obj: Union[BaseObject, dict, list]): element.to_dict() if isinstance(element, BaseObject) else element for element in obj ] - return json.dumps(obj) + return obj -def deserialize(json_str: str, type: Union[Type[BaseObject], Union[Type[BaseObject]]]): - value = json.loads(json_str) - +def deserialize(value: SerializedData, type: Type[BaseObject]) -> str: if get_origin(type) == Union: type = BaseObject._deserialize_union('', value, type) diff --git a/box_sdk_gen/utils.py b/box_sdk_gen/utils.py index ffd691b..dcb162f 100644 --- a/box_sdk_gen/utils.py +++ b/box_sdk_gen/utils.py @@ -7,6 +7,7 @@ from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from .base_object import BaseObject +from .json import sd_to_json from .serialization import serialize ByteStream = BufferedIOBase @@ -104,7 +105,7 @@ def to_string(value: Any) -> Optional[str]: or isinstance(value, list) and isinstance(value[0], BaseObject) ): - return ''.join(serialize(value).split()) + return ''.join(sd_to_json(serialize(value)).split()) if isinstance(value, list): return ','.join(map(to_string, value)) if isinstance(value, Enum): diff --git a/docs/client.md b/docs/client.md new file mode 100644 index 0000000..81dad89 --- /dev/null +++ b/docs/client.md @@ -0,0 +1,63 @@ +# Client + +This is the central entrypoint for all SDK interaction. The BoxClient houses all the API endpoints +divided across resource managers. + + + + +- [Additional headers](#additional-headers) + - [As-User header](#as-user-header) + - [Suppress notifications](#suppress-notifications) + - [Custom headers](#custom-headers) + + + +# Additional headers + +BoxClient provides a convenient methods, which allow passing additional headers, which will be included +in every API call made by the client. + +## As-User header + +The As-User header is used by enterprise admins to make API calls on behalf of their enterprise's users. +This requires the API request to pass an As-User: USER-ID header. For more details see the [documentation on As-User](https://developer.box.com/en/guides/authentication/oauth2/as-user/). + +The following example assume that the client has been instantiated with an access token belonging to an admin-level user +or Service Account with appropriate privileges to make As-User calls. + +Calling the `client.with_as_user_header()` method creates a new client to impersonate user with the provided ID. +All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified. + + + +```python +user_client = client.with_as_user_header(user_id='1234567') +``` + +## Suppress notifications + +If you are making administrative API calls (that is, your application has “Manage an Enterprise” +scope, and the user signing in is a co-admin with the correct "Edit settings for your company" +permission) then you can suppress both email and webhook notifications. This can be used, for +example, for a virus-scanning tool to download copies of everyone’s files in an enterprise, +without every collaborator on the file getting an email. All actions will still appear in users' +updates feed and audit logs. + +> **Note:** This functionality is only available for approved applications. + +Calling the `client.with_suppressed_notifications()` method creates a new client. +For all calls made with the new client the notifications will be suppressed. + +```python +new_client = client.with_suppressed_notifications() +``` + +## Custom headers + +You can also specify the custom set of headers, which will be included in every API call made by client. +Calling the `client.with_extra_headers()` method creates a new client, leaving the original client unmodified. + +```python +new_client = client.with_extra_headers(extra_headers={'customHeader': 'customValue'}) +``` diff --git a/docs/file_requests.md b/docs/file_requests.md index d7180df..8b92048 100644 --- a/docs/file_requests.md +++ b/docs/file_requests.md @@ -14,7 +14,11 @@ This operation is performed by calling function `get_file_request_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-file-requests-id/). -_Currently we don't have an example for calling `get_file_request_by_id` in integration tests_ + + +```python +client.file_requests.get_file_request_by_id(file_request_id=updated_file_request.id) +``` ### Arguments @@ -39,7 +43,11 @@ This operation is performed by calling function `update_file_request_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/put-file-requests-id/). -_Currently we don't have an example for calling `update_file_request_by_id` in integration tests_ + + +```python +client.file_requests.update_file_request_by_id(file_request_id=copied_file_request.id, title='updated title', description='updated description') +``` ### Arguments @@ -77,7 +85,11 @@ This operation is performed by calling function `delete_file_request_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-file-requests-id/). -_Currently we don't have an example for calling `delete_file_request_by_id` in integration tests_ + + +```python +client.file_requests.delete_file_request_by_id(file_request_id=updated_file_request.id) +``` ### Arguments @@ -103,7 +115,11 @@ This operation is performed by calling function `create_file_request_copy`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-file-requests-id-copy/). -_Currently we don't have an example for calling `create_file_request_copy` in integration tests_ + + +```python +client.file_requests.create_file_request_copy(file_request_id=file_request_id, folder=CreateFileRequestCopyFolderArg(id=file_request.folder.id, type=CreateFileRequestCopyFolderArgTypeField.FOLDER.value)) +``` ### Arguments diff --git a/docs/legal_hold_policies.md b/docs/legal_hold_policies.md index a1bcb01..d46fd81 100644 --- a/docs/legal_hold_policies.md +++ b/docs/legal_hold_policies.md @@ -16,7 +16,11 @@ This operation is performed by calling function `get_legal_hold_policies`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-legal-hold-policies/). -_Currently we don't have an example for calling `get_legal_hold_policies` in integration tests_ + + +```python +client.legal_hold_policies.get_legal_hold_policies() +``` ### Arguments @@ -46,7 +50,11 @@ This operation is performed by calling function `create_legal_hold_policy`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-legal-hold-policies/). -_Currently we don't have an example for calling `create_legal_hold_policy` in integration tests_ + + +```python +client.legal_hold_policies.create_legal_hold_policy(policy_name=legal_hold_policy_name, description=legal_hold_description, is_ongoing=True) +``` ### Arguments @@ -78,7 +86,11 @@ This operation is performed by calling function `get_legal_hold_policy_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-legal-hold-policies-id/). -_Currently we don't have an example for calling `get_legal_hold_policy_by_id` in integration tests_ + + +```python +client.legal_hold_policies.get_legal_hold_policy_by_id(legal_hold_policy_id=legal_hold_policy_id) +``` ### Arguments @@ -102,7 +114,11 @@ This operation is performed by calling function `update_legal_hold_policy_by_id` See the endpoint docs at [API Reference](https://developer.box.com/reference/put-legal-hold-policies-id/). -_Currently we don't have an example for calling `update_legal_hold_policy_by_id` in integration tests_ + + +```python +client.legal_hold_policies.update_legal_hold_policy_by_id(legal_hold_policy_id=legal_hold_policy_id, policy_name=updated_legal_hold_policy_name) +``` ### Arguments @@ -135,7 +151,11 @@ This operation is performed by calling function `delete_legal_hold_policy_by_id` See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-legal-hold-policies-id/). -_Currently we don't have an example for calling `delete_legal_hold_policy_by_id` in integration tests_ + + +```python +client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy_id=legal_hold_policy_id) +``` ### Arguments diff --git a/test/client.py b/test/client.py new file mode 100644 index 0000000..e706295 --- /dev/null +++ b/test/client.py @@ -0,0 +1,45 @@ +from box_sdk_gen.utils import to_string + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas import User + +from box_sdk_gen.schemas import UserFull + +from box_sdk_gen.utils import get_uuid + +from test.commons import get_default_client + +client: BoxClient = get_default_client() + + +def testWithAsUserHeader(): + user_name: str = get_uuid() + created_user: User = client.users.create_user( + name=user_name, is_platform_access_only=True + ) + as_user_client: BoxClient = client.with_as_user_header(created_user.id) + admin_user: UserFull = client.users.get_user_me() + assert not to_string(admin_user.name) == user_name + app_user: UserFull = as_user_client.users.get_user_me() + assert to_string(app_user.name) == user_name + client.users.delete_user_by_id(user_id=created_user.id) + + +def testWithSuppressedNotifications(): + new_client: BoxClient = client.with_suppressed_notifications() + user: UserFull = new_client.users.get_user_me() + assert not user.id == '' + + +def testWithExtraHeaders(): + user_name: str = get_uuid() + created_user: User = client.users.create_user( + name=user_name, is_platform_access_only=True + ) + as_user_client: BoxClient = client.with_extra_headers({'As-User': created_user.id}) + admin_user: UserFull = client.users.get_user_me() + assert not to_string(admin_user.name) == user_name + app_user: UserFull = as_user_client.users.get_user_me() + assert to_string(app_user.name) == user_name + client.users.delete_user_by_id(user_id=created_user.id) diff --git a/test/file_requests.py b/test/file_requests.py new file mode 100644 index 0000000..9e3603e --- /dev/null +++ b/test/file_requests.py @@ -0,0 +1,51 @@ +from box_sdk_gen.utils import to_string + +import pytest + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas import FileRequest + +from box_sdk_gen.managers.file_requests import CreateFileRequestCopyFolderArg + +from box_sdk_gen.managers.file_requests import CreateFileRequestCopyFolderArgTypeField + +from box_sdk_gen.utils import get_env_var + +from test.commons import get_default_client_as_user + + +def testGetCopyUpdateDeleteFileRequest(): + file_request_id: str = get_env_var('BOX_FILE_REQUEST_ID') + user_id: str = get_env_var('USER_ID') + client: BoxClient = get_default_client_as_user(user_id) + file_request: FileRequest = client.file_requests.get_file_request_by_id( + file_request_id=file_request_id + ) + assert file_request.id == file_request_id + assert to_string(file_request.type) == 'file_request' + copied_file_request: FileRequest = client.file_requests.create_file_request_copy( + file_request_id=file_request_id, + folder=CreateFileRequestCopyFolderArg( + id=file_request.folder.id, + type=CreateFileRequestCopyFolderArgTypeField.FOLDER.value, + ), + ) + assert not copied_file_request.id == file_request_id + assert copied_file_request.title == file_request.title + assert copied_file_request.description == file_request.description + updated_file_request: FileRequest = client.file_requests.update_file_request_by_id( + file_request_id=copied_file_request.id, + title='updated title', + description='updated description', + ) + assert updated_file_request.id == copied_file_request.id + assert updated_file_request.title == 'updated title' + assert updated_file_request.description == 'updated description' + client.file_requests.delete_file_request_by_id( + file_request_id=updated_file_request.id + ) + with pytest.raises(Exception): + client.file_requests.get_file_request_by_id( + file_request_id=updated_file_request.id + ) diff --git a/test/folder_locks.py b/test/folder_locks.py index 84761f9..70f7314 100644 --- a/test/folder_locks.py +++ b/test/folder_locks.py @@ -4,8 +4,6 @@ from box_sdk_gen.schemas import FolderFull -from box_sdk_gen.managers.folders import CreateFolderParentArg - from box_sdk_gen.schemas import FolderLocks from box_sdk_gen.schemas import FolderLock @@ -18,13 +16,13 @@ from test.commons import get_default_client +from test.commons import create_new_folder + client: BoxClient = get_default_client() def testFolderLocks(): - folder: FolderFull = client.folders.create_folder( - name=get_uuid(), parent=CreateFolderParentArg(id='0') - ) + folder: FolderFull = create_new_folder() folder_locks: FolderLocks = client.folder_locks.get_folder_locks( folder_id=folder.id ) diff --git a/test/legal_hold_policies.py b/test/legal_hold_policies.py new file mode 100644 index 0000000..ad8559c --- /dev/null +++ b/test/legal_hold_policies.py @@ -0,0 +1,47 @@ +from box_sdk_gen.schemas import LegalHoldPolicy + +from box_sdk_gen.schemas import LegalHoldPolicies + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import BoxClient + +from test.commons import get_default_client + +client: BoxClient = get_default_client() + + +def testCreateUpdateGetDeleteLegalHoldPolicy(): + legal_hold_policy_name: str = get_uuid() + legal_hold_description: str = 'test description' + legal_hold_policy: LegalHoldPolicy = ( + client.legal_hold_policies.create_legal_hold_policy( + policy_name=legal_hold_policy_name, + description=legal_hold_description, + is_ongoing=True, + ) + ) + assert legal_hold_policy.policy_name == legal_hold_policy_name + assert legal_hold_policy.description == legal_hold_description + legal_hold_policy_id: str = legal_hold_policy.id + legal_hold_policy_by_id: LegalHoldPolicy = ( + client.legal_hold_policies.get_legal_hold_policy_by_id( + legal_hold_policy_id=legal_hold_policy_id + ) + ) + assert legal_hold_policy_by_id.id == legal_hold_policy_id + legal_hold_policies: LegalHoldPolicies = ( + client.legal_hold_policies.get_legal_hold_policies() + ) + assert len(legal_hold_policies.entries) > 0 + updated_legal_hold_policy_name: str = get_uuid() + updated_legal_hold_policy: LegalHoldPolicy = ( + client.legal_hold_policies.update_legal_hold_policy_by_id( + legal_hold_policy_id=legal_hold_policy_id, + policy_name=updated_legal_hold_policy_name, + ) + ) + assert updated_legal_hold_policy.policy_name == updated_legal_hold_policy_name + client.legal_hold_policies.delete_legal_hold_policy_by_id( + legal_hold_policy_id=legal_hold_policy_id + ) diff --git a/tox.ini b/tox.ini index fca3190..1f1fbd0 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ commands = pytest {posargs} --disable-pytest-warnings deps = -rrequirements-test.txt allowlist_externals = pytest -passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID +passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID [testenv:pycodestyle] commands = @@ -45,7 +45,7 @@ commands = deps = coverage -rrequirements-test.txt -passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID +passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID [testenv:py310-build] description = Build the source and binary wheel packages for distribution.