diff --git a/README.md b/README.md index d18cc6f..939182d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,23 @@ +

+ “box-dev-logo” +

+ # Box Python SDK GENERATED +We are excited to introduce the latest generation (currently in Beta) of Box Python SDK, designed to elevate the developer experience and streamline your integration with the Box Content Cloud. + +With this SDK, you’ll have access to: + +1. Full API Support: The new generation of Box SDKs empowers developers with complete coverage of the Box API ecosystem. You can now access all the latest features and functionalities offered by Box, allowing you to build even more sophisticated and feature-rich applications. +2. Rapid API Updates: Say goodbye to waiting for new Box APIs to be incorporated into the SDK. With our new auto-generation development approach, we can now add new Box APIs to the SDK at a much faster pace (in a matter of days). This means you can leverage the most up-to-date features in your applications without delay. +3. Embedded Documentation: We understand that easy access to information is crucial for developers. With our new approach, we have included comprehensive documentation for all objects and parameters directly in the source code of the SDK. This means you no longer need to look up this information on the developer portal, saving you time and streamlining your development process. +4. Enhanced Convenience Methods: Our commitment to enhancing your development experience continues with the introduction of convenience methods. These methods cover various aspects such as chunk uploads, classification, and much more. +5. Seamless Start: The new SDKs integrate essential functionalities like authentication, automatic retries with exponential backoff, exception handling, request cancellation, and type checking, enabling you to focus solely on your application's business logic. + +Embrace the new generation of Box SDKs and unlock the full potential of the Box Content Cloud. + +# Table of contents + @@ -92,12 +110,11 @@ To run integration tests locally: # Questions, Bugs, and Feature Requests? Need to contact us directly? [Browse the issues -tickets](https://github.com/box/box-python-sdk-generated/issues)! Or, if that +tickets](https://github.com/box/box-python-sdk-gen/issues)! Or, if that doesn't work, [file a new -one](https://github.com/box/box-python-sdk-generated/issues/new) and we will get +one](https://github.com/box/box-python-sdk-gen/issues/new) and we will get back to you. If you have general questions about the Box API, you can -post to the [Box Developer -Forum](https://community.box.com/t5/Developer-Forum/bd-p/DeveloperForum). +post to the [Box Developer Forum](https://forum.box.com/). # Copyright and License diff --git a/box_sdk_gen/fetch.py b/box_sdk_gen/fetch.py index a68f014..b195140 100644 --- a/box_sdk_gen/fetch.py +++ b/box_sdk_gen/fetch.py @@ -42,7 +42,7 @@ class FetchOptions: body: str = None multipart_data: List[MultipartItem] = None content_type: str = "" - response_format: str = None + response_format: Optional[str] = None auth: Authentication = None network_session: NetworkSession = None diff --git a/box_sdk_gen/managers/avatars.py b/box_sdk_gen/managers/avatars.py index 73328e7..42b34f4 100644 --- a/box_sdk_gen/managers/avatars.py +++ b/box_sdk_gen/managers/avatars.py @@ -63,7 +63,7 @@ def create_user_avatar(self, user_id: str, pic: ByteStream, pic_file_name: Optio extra_headers = {} request_body: BaseObject = BaseObject(pic=pic, pic_file_name=pic_file_name, pic_content_type=pic_content_type) headers_map: Dict[str, str] = prepare_params({**extra_headers}) - response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/users/', user_id, '/avatar']), FetchOptions(method='POST', headers=headers_map, multipart_data=[MultipartItem(part_name='pic', file_stream=request_body.pic, content_type=request_body.pic_content_type, file_name=request_body.pic_file_name)], content_type='multipart/form-data', response_format='json', auth=self.auth, network_session=self.network_session)) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/users/', user_id, '/avatar']), FetchOptions(method='POST', headers=headers_map, multipart_data=[MultipartItem(part_name='pic', file_stream=request_body.pic, file_name=request_body.pic_file_name, content_type=request_body.pic_content_type)], content_type='multipart/form-data', response_format='json', auth=self.auth, network_session=self.network_session)) return UserAvatar.from_dict(json.loads(response.text)) def delete_user_avatar(self, user_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ diff --git a/box_sdk_gen/managers/chunked_uploads.py b/box_sdk_gen/managers/chunked_uploads.py index 18ccaed..2f91e9b 100644 --- a/box_sdk_gen/managers/chunked_uploads.py +++ b/box_sdk_gen/managers/chunked_uploads.py @@ -96,12 +96,14 @@ def get_file_upload_session_by_id(self, upload_session_id: str, extra_headers: O headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://upload.box.com/api/2.0/files/upload_sessions/', upload_session_id]), FetchOptions(method='GET', headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return UploadSession.from_dict(json.loads(response.text)) - def upload_file_part(self, upload_session_id: str, digest: str, content_range: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> UploadedPart: + def upload_file_part(self, upload_session_id: str, request_body: ByteStream, digest: str, content_range: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> UploadedPart: """ Updates a chunk of an upload session for a file. :param upload_session_id: The ID of the upload session. Example: "D5E3F7A" :type upload_session_id: str + :param request_body: Request body of uploadFilePart method + :type request_body: ByteStream :param digest: The [RFC3230][1] message digest of the chunk uploaded. Only SHA1 is supported. The SHA1 digest must be base64 encoded. The format of this header is as @@ -127,7 +129,6 @@ def upload_file_part(self, upload_session_id: str, digest: str, content_range: s """ if extra_headers is None: extra_headers = {} - request_body: ByteStream = ByteStream() 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/', upload_session_id]), FetchOptions(method='PUT', headers=headers_map, body=request_body, content_type='application/octet-stream', response_format='json', auth=self.auth, network_session=self.network_session)) return UploadedPart.from_dict(json.loads(response.text)) diff --git a/box_sdk_gen/managers/classifications.py b/box_sdk_gen/managers/classifications.py index 4a5483c..bad500f 100644 --- a/box_sdk_gen/managers/classifications.py +++ b/box_sdk_gen/managers/classifications.py @@ -1,14 +1,14 @@ -from enum import Enum - from typing import Optional from typing import Dict -import json +from box_sdk_gen.base_object import BaseObject + +from enum import Enum from typing import List -from typing import Union +import json from box_sdk_gen.base_object import BaseObject @@ -32,6 +32,139 @@ from box_sdk_gen.fetch import FetchResponse +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataFieldClassificationField(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'classification_definition': 'classificationDefinition', 'color_id': 'colorID', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'classificationDefinition': 'classification_definition', 'colorID': 'color_id', **BaseObject._json_to_fields_mapping} + def __init__(self, classification_definition: Optional[str] = None, color_id: Optional[int] = None, **kwargs): + """ + :param classification_definition: A longer description of the classification. + :type classification_definition: Optional[str], optional + :param color_id: An internal Box identifier used to assign a color to + a classification label. + Mapping between a `colorID` and a color may change + without notice. Currently, the color mappings are as + follows. + * `0`: Yellow + * `1`: Orange + * `2`: Watermelon red + * `3`: Purple rain + * `4`: Light blue + * `5`: Dark blue + * `6`: Light green + * `7`: Gray + :type color_id: Optional[int], optional + """ + super().__init__(**kwargs) + self.classification_definition = classification_definition + self.color_id = color_id + +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataField(BaseObject): + def __init__(self, key: str, classification: Optional[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataFieldClassificationField] = None, **kwargs): + """ + :param key: The label of the classification as shown in the web and + mobile interfaces. This is the only field required to + add a classification. + :type key: str + :param classification: Additional details for the classification. + :type classification: Optional[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataFieldClassificationField], optional + """ + super().__init__(**kwargs) + self.key = key + self.classification = classification + +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'field_key': 'fieldKey', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'fieldKey': 'field_key', **BaseObject._json_to_fields_mapping} + def __init__(self, op: str, field_key: str, data: UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataField, **kwargs): + """ + :param op: `addEnumOption` + :type op: str + :param field_key: `Box__Security__Classification__Key` + :type field_key: str + :param data: The details of the classification to add. + :type data: UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArgDataField + """ + super().__init__(**kwargs) + self.op = op + self.field_key = field_key + self.data = data + +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArgDataFieldClassificationField(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'classification_definition': 'classificationDefinition', 'color_id': 'colorID', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'classificationDefinition': 'classification_definition', 'colorID': 'color_id', **BaseObject._json_to_fields_mapping} + def __init__(self, classification_definition: Optional[str] = None, color_id: Optional[int] = None, **kwargs): + """ + :param classification_definition: A longer description of the classification. + :type classification_definition: Optional[str], optional + :param color_id: An internal Box identifier used to assign a color to + a classification label. + Mapping between a `colorID` and a color may change + without notice. Currently, the color mappings are as + follows. + * `0`: Yellow + * `1`: Orange + * `2`: Watermelon red + * `3`: Purple rain + * `4`: Light blue + * `5`: Dark blue + * `6`: Light green + * `7`: Gray + :type color_id: Optional[int], optional + """ + super().__init__(**kwargs) + self.classification_definition = classification_definition + self.color_id = color_id + +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArgDataField(BaseObject): + def __init__(self, key: str, classification: Optional[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArgDataFieldClassificationField] = None, **kwargs): + """ + :param key: A new label for the classification, as it will be + shown in the web and mobile interfaces. + :type key: str + :param classification: Additional details for the classification. + :type classification: Optional[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArgDataFieldClassificationField], optional + """ + super().__init__(**kwargs) + self.key = key + self.classification = classification + +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'field_key': 'fieldKey', 'enum_option_key': 'enumOptionKey', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'fieldKey': 'field_key', 'enumOptionKey': 'enum_option_key', **BaseObject._json_to_fields_mapping} + def __init__(self, op: str, field_key: str, enum_option_key: str, data: UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArgDataField, **kwargs): + """ + :param op: `editEnumOption` + :type op: str + :param field_key: `Box__Security__Classification__Key` + :type field_key: str + :param enum_option_key: The original label of the classification to change. + :type enum_option_key: str + :param data: The details of the updated classification. + :type data: UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArgDataField + """ + super().__init__(**kwargs) + self.op = op + self.field_key = field_key + self.enum_option_key = enum_option_key + self.data = data + +class UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaDeleteRequestBodyArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'field_key': 'fieldKey', 'enum_option_key': 'enumOptionKey', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'fieldKey': 'field_key', 'enumOptionKey': 'enum_option_key', **BaseObject._json_to_fields_mapping} + def __init__(self, op: str, field_key: str, enum_option_key: str, **kwargs): + """ + :param op: `removeEnumOption` + :type op: str + :param field_key: `Box__Security__Classification__Key` + :type field_key: str + :param enum_option_key: The label of the classification to remove. + :type enum_option_key: str + """ + super().__init__(**kwargs) + self.op = op + self.field_key = field_key + self.enum_option_key = enum_option_key + class CreateMetadataTemplateSchemaClassificationScopeArg(str, Enum): ENTERPRISE = 'enterprise' @@ -41,6 +174,89 @@ class CreateMetadataTemplateSchemaClassificationTemplateKeyArg(str, Enum): class CreateMetadataTemplateSchemaClassificationDisplayNameArg(str, Enum): CLASSIFICATION = 'Classification' +class CreateMetadataTemplateSchemaClassificationFieldsArgTypeField(str, Enum): + ENUM = 'enum' + +class CreateMetadataTemplateSchemaClassificationFieldsArgKeyField(str, Enum): + BOX__SECURITY__CLASSIFICATION__KEY = 'Box__Security__Classification__Key' + +class CreateMetadataTemplateSchemaClassificationFieldsArgDisplayNameField(str, Enum): + CLASSIFICATION = 'Classification' + +class CreateMetadataTemplateSchemaClassificationFieldsArgOptionsFieldStaticConfigFieldClassificationField(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'classification_definition': 'classificationDefinition', 'color_id': 'colorID', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'classificationDefinition': 'classification_definition', 'colorID': 'color_id', **BaseObject._json_to_fields_mapping} + def __init__(self, classification_definition: Optional[str] = None, color_id: Optional[int] = None, **kwargs): + """ + :param classification_definition: A longer description of the classification. + :type classification_definition: Optional[str], optional + :param color_id: An identifier used to assign a color to + a classification label. + Mapping between a `colorID` and a color may + change without notice. Currently, the color + mappings are as follows. + * `0`: Yellow + * `1`: Orange + * `2`: Watermelon red + * `3`: Purple rain + * `4`: Light blue + * `5`: Dark blue + * `6`: Light green + * `7`: Gray + :type color_id: Optional[int], optional + """ + super().__init__(**kwargs) + self.classification_definition = classification_definition + self.color_id = color_id + +class CreateMetadataTemplateSchemaClassificationFieldsArgOptionsFieldStaticConfigField(BaseObject): + def __init__(self, classification: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgOptionsFieldStaticConfigFieldClassificationField] = None, **kwargs): + """ + :param classification: Additional information about the classification. + :type classification: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgOptionsFieldStaticConfigFieldClassificationField], optional + """ + super().__init__(**kwargs) + self.classification = classification + +class CreateMetadataTemplateSchemaClassificationFieldsArgOptionsField(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'static_config': 'staticConfig', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'staticConfig': 'static_config', **BaseObject._json_to_fields_mapping} + def __init__(self, key: Optional[str] = None, static_config: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgOptionsFieldStaticConfigField] = None, **kwargs): + """ + :param key: The display name and key this classification. This + will be show in the Box UI. + :type key: Optional[str], optional + :param static_config: Additional information about the classification. + :type static_config: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgOptionsFieldStaticConfigField], optional + """ + super().__init__(**kwargs) + self.key = key + self.static_config = static_config + +class CreateMetadataTemplateSchemaClassificationFieldsArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'display_name': 'displayName', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'displayName': 'display_name', **BaseObject._json_to_fields_mapping} + def __init__(self, type: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgTypeField] = None, key: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgKeyField] = None, display_name: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgDisplayNameField] = None, hidden: Optional[bool] = None, options: Optional[List[CreateMetadataTemplateSchemaClassificationFieldsArgOptionsField]] = None, **kwargs): + """ + :param type: `enum` + :type type: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgTypeField], optional + :param key: `Box__Security__Classification__Key` + :type key: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgKeyField], optional + :param display_name: `Classification` + :type display_name: Optional[CreateMetadataTemplateSchemaClassificationFieldsArgDisplayNameField], optional + :param hidden: `false` + :type hidden: Optional[bool], optional + :param options: The actual list of classifications that are present on + this template. + :type options: Optional[List[CreateMetadataTemplateSchemaClassificationFieldsArgOptionsField]], optional + """ + super().__init__(**kwargs) + self.type = type + self.key = key + self.display_name = display_name + self.hidden = hidden + self.options = options + class ClassificationsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -82,7 +298,82 @@ def delete_metadata_template_enterprise_security_classification_schema(self, ext 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']), FetchOptions(method='DELETE', headers=headers_map, response_format=None, auth=self.auth, network_session=self.network_session)) return None - def create_metadata_template_schema_classification(self, scope: CreateMetadataTemplateSchemaClassificationScopeArg, display_name: CreateMetadataTemplateSchemaClassificationDisplayNameArg, template_key: Optional[CreateMetadataTemplateSchemaClassificationTemplateKeyArg] = None, hidden: Optional[bool] = None, copy_instance_on_item_copy: Optional[bool] = None, fields: Optional[List] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ClassificationTemplate: + def update_metadata_template_enterprise_security_classification_schema_add(self, request_body: List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ClassificationTemplate: + """ + Adds one or more new classifications to the list of classifications + + available to the enterprise. + + + This API can also be called by including the enterprise ID in the + + + URL explicitly, for example + + + `/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`. + + :param request_body: Request body of updateMetadataTemplateEnterpriseSecurityClassificationSchemaAdd method + :type request_body: List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#add']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return ClassificationTemplate.from_dict(json.loads(response.text)) + def update_metadata_template_enterprise_security_classification_schema_update(self, request_body: List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ClassificationTemplate: + """ + Updates the labels and descriptions of one or more classifications + + available to the enterprise. + + + This API can also be called by including the enterprise ID in the + + + URL explicitly, for example + + + `/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`. + + :param request_body: Request body of updateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdate method + :type request_body: List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#update']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return ClassificationTemplate.from_dict(json.loads(response.text)) + def update_metadata_template_enterprise_security_classification_schema_delete(self, request_body: List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaDeleteRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ClassificationTemplate: + """ + Removes a classification from the list of classifications + + available to the enterprise. + + + This API can also be called by including the enterprise ID in the + + + URL explicitly, for example + + + `/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`. + + :param request_body: Request body of updateMetadataTemplateEnterpriseSecurityClassificationSchemaDelete method + :type request_body: List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaDeleteRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema#delete']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return ClassificationTemplate.from_dict(json.loads(response.text)) + def create_metadata_template_schema_classification(self, scope: CreateMetadataTemplateSchemaClassificationScopeArg, display_name: CreateMetadataTemplateSchemaClassificationDisplayNameArg, template_key: Optional[CreateMetadataTemplateSchemaClassificationTemplateKeyArg] = None, hidden: Optional[bool] = None, copy_instance_on_item_copy: Optional[bool] = None, fields: Optional[List[CreateMetadataTemplateSchemaClassificationFieldsArg]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ClassificationTemplate: """ When an enterprise does not yet have any classifications, this API call @@ -114,13 +405,13 @@ def create_metadata_template_schema_classification(self, scope: CreateMetadataTe :type copy_instance_on_item_copy: Optional[bool], optional :param fields: The classification template holds one field, which holds all the valid classification values. - :type fields: Optional[List], optional + :type fields: Optional[List[CreateMetadataTemplateSchemaClassificationFieldsArg]], optional :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject(scope=scope, template_key=template_key, display_name=display_name, hidden=hidden, copy_instance_on_item_copy=copy_instance_on_item_copy, fields=fields) + request_body: BaseObject = BaseObject(scope=scope, templateKey=template_key, displayName=display_name, hidden=hidden, copyInstanceOnItemCopy=copy_instance_on_item_copy, fields=fields) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/schema#classifications']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return ClassificationTemplate.from_dict(json.loads(response.text)) \ No newline at end of file diff --git a/box_sdk_gen/managers/file_classifications.py b/box_sdk_gen/managers/file_classifications.py index 5ee77e1..210397e 100644 --- a/box_sdk_gen/managers/file_classifications.py +++ b/box_sdk_gen/managers/file_classifications.py @@ -1,9 +1,15 @@ +from enum import Enum + from typing import Optional +from box_sdk_gen.base_object import BaseObject + from typing import Dict import json +from typing import List + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Classification @@ -26,6 +32,31 @@ from box_sdk_gen.fetch import FetchResponse +class UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgOpField(str, Enum): + REPLACE = 'replace' + +class UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgPathField(str, Enum): + _BOX__SECURITY__CLASSIFICATION__KEY = '/Box__Security__Classification__Key' + +class UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArg(BaseObject): + def __init__(self, op: Optional[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgOpField] = None, path: Optional[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgPathField] = None, value: Optional[str] = None, **kwargs): + """ + :param op: `replace` + :type op: Optional[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgOpField], optional + :param path: `/Box__Security__Classification__Key` + :type path: Optional[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArgPathField], optional + :param value: The name of the classification to apply to this file. + To list the available classifications in an enterprise, + use the classification API to retrieve the + [classification template](e://get_metadata_templates_enterprise_securityClassification-6VMVochwUWo_schema) + which lists all available classification keys. + :type value: Optional[str], optional + """ + super().__init__(**kwargs) + self.op = op + self.path = path + self.value = value + class FileClassificationsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -95,10 +126,40 @@ def create_file_metadata_enterprise_security_classification(self, file_id: str, """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject(box_security_classification_key=box_security_classification_key) + request_body: BaseObject = BaseObject(Box__Security__Classification__Key=box_security_classification_key) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/enterprise/securityClassification-6VMVochwUWo']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return Classification.from_dict(json.loads(response.text)) + def update_file_metadata_enterprise_security_classification(self, file_id: str, request_body: List[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Classification: + """ + Updates a classification on a file. + + The classification can only be updated if a classification has already been + + + applied to the file before. When editing classifications, only values are + + + defined for the enterprise will be accepted. + + :param file_id: The unique identifier that represents a file. + The ID for any file can be determined + by visiting a file in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/files/123` + the `file_id` is `123`. + Example: "12345" + :type file_id: str + :param request_body: Request body of updateFileMetadataEnterpriseSecurityClassification method + :type request_body: List[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/enterprise/securityClassification-6VMVochwUWo']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return Classification.from_dict(json.loads(response.text)) def delete_file_metadata_enterprise_security_classification(self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Removes any classifications from a file. diff --git a/box_sdk_gen/managers/file_metadata.py b/box_sdk_gen/managers/file_metadata.py index 4ef59d0..03704c5 100644 --- a/box_sdk_gen/managers/file_metadata.py +++ b/box_sdk_gen/managers/file_metadata.py @@ -1,12 +1,14 @@ from enum import Enum -from typing import Optional - from typing import Dict +from box_sdk_gen.base_object import BaseObject + +from typing import Optional + import json -from box_sdk_gen.base_object import BaseObject +from typing import List from box_sdk_gen.schemas import Metadatas @@ -40,6 +42,55 @@ class CreateFileMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' +class CreateFileMetadataByIdRequestBodyArg(BaseObject): + pass + +class UpdateFileMetadataByIdScopeArg(str, Enum): + GLOBAL = 'global' + ENTERPRISE = 'enterprise' + +class UpdateFileMetadataByIdRequestBodyArgOpField(str, Enum): + ADD = 'add' + REPLACE = 'replace' + REMOVE = 'remove' + TEST = 'test' + MOVE = 'move' + COPY = 'copy' + +class UpdateFileMetadataByIdRequestBodyArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'from_': 'from', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'from': 'from_', **BaseObject._json_to_fields_mapping} + def __init__(self, op: Optional[UpdateFileMetadataByIdRequestBodyArgOpField] = None, path: Optional[str] = None, value: Optional[str] = None, from_: Optional[str] = None, **kwargs): + """ + :param op: The type of change to perform on the template. Some + of these are hazardous as they will change existing templates. + :type op: Optional[UpdateFileMetadataByIdRequestBodyArgOpField], optional + :param path: The location in the metadata JSON object + to apply the changes to, in the format of a + [JSON-Pointer](https://tools.ietf.org/html/rfc6901). + The path must always be prefixed with a `/` to represent the root + of the template. The characters `~` and `/` are reserved + characters and must be escaped in the key. + :type path: Optional[str], optional + :param value: The value to be set or tested. + Required for `add`, `replace`, and `test` operations. For `add`, + if the value exists already the previous value will be overwritten + by the new value. For `replace`, the value must exist before + replacing. + For `test`, the existing value at the `path` location must match + the specified value. + :type value: Optional[str], optional + :param from_: The location in the metadata JSON object to move or copy a value + from. Required for `move` or `copy` operations and must be in the + format of a [JSON-Pointer](https://tools.ietf.org/html/rfc6901). + :type from_: Optional[str], optional + """ + super().__init__(**kwargs) + self.op = op + self.path = path + self.value = value + self.from_ = from_ + class DeleteFileMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' @@ -95,7 +146,7 @@ def get_file_metadata_by_id(self, file_id: str, scope: GetFileMetadataByIdScopeA headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/', scope, '/', template_key]), FetchOptions(method='GET', headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return MetadataFull.from_dict(json.loads(response.text)) - def create_file_metadata_by_id(self, file_id: str, scope: CreateFileMetadataByIdScopeArg, template_key: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Metadata: + def create_file_metadata_by_id(self, file_id: str, scope: CreateFileMetadataByIdScopeArg, template_key: str, request_body: CreateFileMetadataByIdRequestBodyArg, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Metadata: """ Applies an instance of a metadata template to a file. @@ -121,15 +172,58 @@ def create_file_metadata_by_id(self, file_id: str, scope: CreateFileMetadataById :param template_key: The name of the metadata template Example: "properties" :type template_key: str + :param request_body: Request body of createFileMetadataById method + :type request_body: CreateFileMetadataByIdRequestBodyArg :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject() headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/', scope, '/', template_key]), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return Metadata.from_dict(json.loads(response.text)) + def update_file_metadata_by_id(self, file_id: str, scope: UpdateFileMetadataByIdScopeArg, template_key: str, request_body: List[UpdateFileMetadataByIdRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Metadata: + """ + Updates a piece of metadata on a file. + + The metadata instance can only be updated if the template has already been + + + applied to the file before. When editing metadata, only values that match + + + the metadata template schema will be accepted. + + + The update is applied atomically. If any errors occur during the + + + application of the operations, the metadata instance will not be changed. + + :param file_id: The unique identifier that represents a file. + The ID for any file can be determined + by visiting a file in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/files/123` + the `file_id` is `123`. + Example: "12345" + :type file_id: str + :param scope: The scope of the metadata template + Example: "global" + :type scope: UpdateFileMetadataByIdScopeArg + :param template_key: The name of the metadata template + Example: "properties" + :type template_key: str + :param request_body: Request body of updateFileMetadataById method + :type request_body: List[UpdateFileMetadataByIdRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/', scope, '/', template_key]), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return Metadata.from_dict(json.loads(response.text)) def delete_file_metadata_by_id(self, file_id: str, scope: DeleteFileMetadataByIdScopeArg, template_key: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Deletes a piece of file metadata. diff --git a/box_sdk_gen/managers/files.py b/box_sdk_gen/managers/files.py index f82f2bf..20202f0 100644 --- a/box_sdk_gen/managers/files.py +++ b/box_sdk_gen/managers/files.py @@ -132,6 +132,18 @@ def __init__(self, can_download: Optional[UpdateFileByIdPermissionsArgCanDownloa super().__init__(**kwargs) self.can_download = can_download +class UpdateFileByIdCollectionsArg(BaseObject): + def __init__(self, id: Optional[str] = None, type: Optional[str] = None, **kwargs): + """ + :param id: The unique identifier for this object + :type id: Optional[str], optional + :param type: The type for this object + :type type: Optional[str], optional + """ + super().__init__(**kwargs) + self.id = id + self.type = type + class CopyFileParentArg(BaseObject): def __init__(self, id: str, **kwargs): """ @@ -211,7 +223,7 @@ def get_file_by_id(self, file_id: str, fields: Optional[str] = None, if_none_mat 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/', file_id]), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return FileFull.from_dict(json.loads(response.text)) - def update_file_by_id(self, file_id: str, name: Optional[str] = None, description: Optional[str] = None, parent: Optional[UpdateFileByIdParentArg] = None, shared_link: Optional[UpdateFileByIdSharedLinkArg] = None, lock: Optional[UpdateFileByIdLockArg] = None, disposition_at: Optional[str] = None, permissions: Optional[UpdateFileByIdPermissionsArg] = None, collections: Optional[List] = None, tags: Optional[List[str]] = None, fields: Optional[str] = None, if_match: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> FileFull: + def update_file_by_id(self, file_id: str, name: Optional[str] = None, description: Optional[str] = None, parent: Optional[UpdateFileByIdParentArg] = None, shared_link: Optional[UpdateFileByIdSharedLinkArg] = None, lock: Optional[UpdateFileByIdLockArg] = None, disposition_at: Optional[str] = None, permissions: Optional[UpdateFileByIdPermissionsArg] = None, collections: Optional[List[UpdateFileByIdCollectionsArg]] = None, tags: Optional[List[str]] = None, fields: Optional[str] = None, if_match: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> FileFull: """ Updates a file. This can be used to rename or move a file, @@ -251,7 +263,7 @@ def update_file_by_id(self, file_id: str, name: Optional[str] = None, descriptio Passing an empty array `[]` or `null` will remove the file from all collections. [1]: e://get-collections - :type collections: Optional[List], optional + :type collections: Optional[List[UpdateFileByIdCollectionsArg]], optional :param tags: The tags for this item. These tags are shown in the Box web app and mobile apps next to an item. To add or remove a tag, retrieve the item's current tags, diff --git a/box_sdk_gen/managers/folder_classifications.py b/box_sdk_gen/managers/folder_classifications.py index 5679032..de1f5eb 100644 --- a/box_sdk_gen/managers/folder_classifications.py +++ b/box_sdk_gen/managers/folder_classifications.py @@ -1,9 +1,15 @@ +from enum import Enum + from typing import Optional +from box_sdk_gen.base_object import BaseObject + from typing import Dict import json +from typing import List + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Classification @@ -26,6 +32,31 @@ from box_sdk_gen.fetch import FetchResponse +class UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgOpField(str, Enum): + REPLACE = 'replace' + +class UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgPathField(str, Enum): + _BOX__SECURITY__CLASSIFICATION__KEY = '/Box__Security__Classification__Key' + +class UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArg(BaseObject): + def __init__(self, op: Optional[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgOpField] = None, path: Optional[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgPathField] = None, value: Optional[str] = None, **kwargs): + """ + :param op: `replace` + :type op: Optional[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgOpField], optional + :param path: `/Box__Security__Classification__Key` + :type path: Optional[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArgPathField], optional + :param value: The name of the classification to apply to this folder. + To list the available classifications in an enterprise, + use the classification API to retrieve the + [classification template](e://get_metadata_templates_enterprise_securityClassification-6VMVochwUWo_schema) + which lists all available classification keys. + :type value: Optional[str], optional + """ + super().__init__(**kwargs) + self.op = op + self.path = path + self.value = value + class FolderClassificationsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -99,10 +130,42 @@ def create_folder_metadata_enterprise_security_classification(self, folder_id: s """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject(box_security_classification_key=box_security_classification_key) + request_body: BaseObject = BaseObject(Box__Security__Classification__Key=box_security_classification_key) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/folders/', folder_id, '/metadata/enterprise/securityClassification-6VMVochwUWo']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return Classification.from_dict(json.loads(response.text)) + def update_folder_metadata_enterprise_security_classification(self, folder_id: str, request_body: List[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Classification: + """ + Updates a classification on a folder. + + The classification can only be updated if a classification has already been + + + applied to the folder before. When editing classifications, only values are + + + defined for the enterprise will be accepted. + + :param folder_id: The unique identifier that represent a folder. + The ID for any folder can be determined + by visiting this folder in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/folder/123` + the `folder_id` is `123`. + The root folder of a Box account is + always represented by the ID `0`. + Example: "12345" + :type folder_id: str + :param request_body: Request body of updateFolderMetadataEnterpriseSecurityClassification method + :type request_body: List[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/folders/', folder_id, '/metadata/enterprise/securityClassification-6VMVochwUWo']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return Classification.from_dict(json.loads(response.text)) def delete_folder_metadata_enterprise_security_classification(self, folder_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Removes any classifications from a folder. diff --git a/box_sdk_gen/managers/folder_metadata.py b/box_sdk_gen/managers/folder_metadata.py index 30b7c7f..bae9909 100644 --- a/box_sdk_gen/managers/folder_metadata.py +++ b/box_sdk_gen/managers/folder_metadata.py @@ -1,12 +1,14 @@ from enum import Enum -from typing import Optional - from typing import Dict +from box_sdk_gen.base_object import BaseObject + +from typing import Optional + import json -from box_sdk_gen.base_object import BaseObject +from typing import List from box_sdk_gen.schemas import Metadatas @@ -38,6 +40,55 @@ class CreateFolderMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' +class CreateFolderMetadataByIdRequestBodyArg(BaseObject): + pass + +class UpdateFolderMetadataByIdScopeArg(str, Enum): + GLOBAL = 'global' + ENTERPRISE = 'enterprise' + +class UpdateFolderMetadataByIdRequestBodyArgOpField(str, Enum): + ADD = 'add' + REPLACE = 'replace' + REMOVE = 'remove' + TEST = 'test' + MOVE = 'move' + COPY = 'copy' + +class UpdateFolderMetadataByIdRequestBodyArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'from_': 'from', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'from': 'from_', **BaseObject._json_to_fields_mapping} + def __init__(self, op: Optional[UpdateFolderMetadataByIdRequestBodyArgOpField] = None, path: Optional[str] = None, value: Optional[str] = None, from_: Optional[str] = None, **kwargs): + """ + :param op: The type of change to perform on the template. Some + of these are hazardous as they will change existing templates. + :type op: Optional[UpdateFolderMetadataByIdRequestBodyArgOpField], optional + :param path: The location in the metadata JSON object + to apply the changes to, in the format of a + [JSON-Pointer](https://tools.ietf.org/html/rfc6901). + The path must always be prefixed with a `/` to represent the root + of the template. The characters `~` and `/` are reserved + characters and must be escaped in the key. + :type path: Optional[str], optional + :param value: The value to be set or tested. + Required for `add`, `replace`, and `test` operations. For `add`, + if the value exists already the previous value will be overwritten + by the new value. For `replace`, the value must exist before + replacing. + For `test`, the existing value at the `path` location must match + the specified value. + :type value: Optional[str], optional + :param from_: The location in the metadata JSON object to move or copy a value + from. Required for `move` or `copy` operations and must be in the + format of a [JSON-Pointer](https://tools.ietf.org/html/rfc6901). + :type from_: Optional[str], optional + """ + super().__init__(**kwargs) + self.op = op + self.path = path + self.value = value + self.from_ = from_ + class DeleteFolderMetadataByIdScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' @@ -100,7 +151,7 @@ def get_folder_metadata_by_id(self, folder_id: str, scope: GetFolderMetadataById headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/folders/', folder_id, '/metadata/', scope, '/', template_key]), FetchOptions(method='GET', headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return Metadata.from_dict(json.loads(response.text)) - def create_folder_metadata_by_id(self, folder_id: str, scope: CreateFolderMetadataByIdScopeArg, template_key: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Metadata: + def create_folder_metadata_by_id(self, folder_id: str, scope: CreateFolderMetadataByIdScopeArg, template_key: str, request_body: CreateFolderMetadataByIdRequestBodyArg, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Metadata: """ Applies an instance of a metadata template to a folder. @@ -137,15 +188,60 @@ def create_folder_metadata_by_id(self, folder_id: str, scope: CreateFolderMetada :param template_key: The name of the metadata template Example: "properties" :type template_key: str + :param request_body: Request body of createFolderMetadataById method + :type request_body: CreateFolderMetadataByIdRequestBodyArg :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject() headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/folders/', folder_id, '/metadata/', scope, '/', template_key]), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return Metadata.from_dict(json.loads(response.text)) + def update_folder_metadata_by_id(self, folder_id: str, scope: UpdateFolderMetadataByIdScopeArg, template_key: str, request_body: List[UpdateFolderMetadataByIdRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Metadata: + """ + Updates a piece of metadata on a folder. + + The metadata instance can only be updated if the template has already been + + + applied to the folder before. When editing metadata, only values that match + + + the metadata template schema will be accepted. + + + The update is applied atomically. If any errors occur during the + + + application of the operations, the metadata instance will not be changed. + + :param folder_id: The unique identifier that represent a folder. + The ID for any folder can be determined + by visiting this folder in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/folder/123` + the `folder_id` is `123`. + The root folder of a Box account is + always represented by the ID `0`. + Example: "12345" + :type folder_id: str + :param scope: The scope of the metadata template + Example: "global" + :type scope: UpdateFolderMetadataByIdScopeArg + :param template_key: The name of the metadata template + Example: "properties" + :type template_key: str + :param request_body: Request body of updateFolderMetadataById method + :type request_body: List[UpdateFolderMetadataByIdRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/folders/', folder_id, '/metadata/', scope, '/', template_key]), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return Metadata.from_dict(json.loads(response.text)) def delete_folder_metadata_by_id(self, folder_id: str, scope: DeleteFolderMetadataByIdScopeArg, template_key: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Deletes a piece of folder metadata. diff --git a/box_sdk_gen/managers/folders.py b/box_sdk_gen/managers/folders.py index 487e63e..6f5cd18 100644 --- a/box_sdk_gen/managers/folders.py +++ b/box_sdk_gen/managers/folders.py @@ -134,6 +134,18 @@ def __init__(self, access: Optional[UpdateFolderByIdFolderUploadEmailArgAccessFi super().__init__(**kwargs) self.access = access +class UpdateFolderByIdCollectionsArg(BaseObject): + def __init__(self, id: Optional[str] = None, type: Optional[str] = None, **kwargs): + """ + :param id: The unique identifier for this object + :type id: Optional[str], optional + :param type: The type for this object + :type type: Optional[str], optional + """ + super().__init__(**kwargs) + self.id = id + self.type = type + class GetFolderItemsSortArg(str, Enum): ID = 'id' NAME = 'name' @@ -297,7 +309,7 @@ def get_folder_by_id(self, folder_id: str, fields: Optional[str] = None, sort: O 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/', folder_id]), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return FolderFull.from_dict(json.loads(response.text)) - def update_folder_by_id(self, folder_id: str, name: Optional[str] = None, description: Optional[str] = None, sync_state: Optional[UpdateFolderByIdSyncStateArg] = None, can_non_owners_invite: Optional[bool] = None, parent: Optional[UpdateFolderByIdParentArg] = None, shared_link: Optional[UpdateFolderByIdSharedLinkArg] = None, folder_upload_email: Optional[UpdateFolderByIdFolderUploadEmailArg] = None, tags: Optional[List[str]] = None, is_collaboration_restricted_to_enterprise: Optional[bool] = None, collections: Optional[List] = None, can_non_owners_view_collaborators: Optional[bool] = None, fields: Optional[str] = None, if_match: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> FolderFull: + def update_folder_by_id(self, folder_id: str, name: Optional[str] = None, description: Optional[str] = None, sync_state: Optional[UpdateFolderByIdSyncStateArg] = None, can_non_owners_invite: Optional[bool] = None, parent: Optional[UpdateFolderByIdParentArg] = None, shared_link: Optional[UpdateFolderByIdSharedLinkArg] = None, folder_upload_email: Optional[UpdateFolderByIdFolderUploadEmailArg] = None, tags: Optional[List[str]] = None, is_collaboration_restricted_to_enterprise: Optional[bool] = None, collections: Optional[List[UpdateFolderByIdCollectionsArg]] = None, can_non_owners_view_collaborators: Optional[bool] = None, fields: Optional[str] = None, if_match: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> FolderFull: """ Updates a folder. This can be also be used to move the folder, @@ -346,7 +358,7 @@ def update_folder_by_id(self, folder_id: str, name: Optional[str] = None, descri Passing an empty array `[]` or `null` will remove the folder from all collections. [1]: e://get-collections - :type collections: Optional[List], optional + :type collections: Optional[List[UpdateFolderByIdCollectionsArg]], optional :param can_non_owners_view_collaborators: Restricts collaborators who are not the owner of this folder from viewing other collaborations on this folder. diff --git a/box_sdk_gen/managers/integration_mappings.py b/box_sdk_gen/managers/integration_mappings.py index f4d0291..bdecc11 100644 --- a/box_sdk_gen/managers/integration_mappings.py +++ b/box_sdk_gen/managers/integration_mappings.py @@ -1,13 +1,13 @@ from enum import Enum -from box_sdk_gen.base_object import BaseObject - from typing import Optional from typing import Dict import json +from box_sdk_gen.schemas import IntegrationMappingPartnerItemSlack + from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import IntegrationMappings @@ -44,26 +44,6 @@ class GetIntegrationMappingSlackPartnerItemTypeArg(str, Enum): class GetIntegrationMappingSlackBoxItemTypeArg(str, Enum): FOLDER = 'folder' -class CreateIntegrationMappingSlackPartnerItemArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class CreateIntegrationMappingSlackBoxItemArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class CreateIntegrationMappingSlackOptionsArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class UpdateIntegrationMappingSlackByIdBoxItemArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class UpdateIntegrationMappingSlackByIdOptionsArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - class IntegrationMappingsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -102,7 +82,7 @@ def get_integration_mapping_slack(self, marker: Optional[str] = None, limit: Opt headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/integration_mappings/slack']), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return IntegrationMappings.from_dict(json.loads(response.text)) - def create_integration_mapping_slack(self, partner_item: CreateIntegrationMappingSlackPartnerItemArg, box_item: CreateIntegrationMappingSlackBoxItemArg, options: Optional[CreateIntegrationMappingSlackOptionsArg] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> IntegrationMapping: + def create_integration_mapping_slack(self, partner_item: IntegrationMappingPartnerItemSlack, box_item: IntegrationMappingBoxItemSlack, options: Optional[IntegrationMappingSlackOptions] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> IntegrationMapping: """ Creates a [Slack integration mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack) @@ -123,7 +103,7 @@ def create_integration_mapping_slack(self, partner_item: CreateIntegrationMappin headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/integration_mappings/slack']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return IntegrationMapping.from_dict(json.loads(response.text)) - def update_integration_mapping_slack_by_id(self, integration_mapping_id: str, box_item: Optional[UpdateIntegrationMappingSlackByIdBoxItemArg] = None, options: Optional[UpdateIntegrationMappingSlackByIdOptionsArg] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> IntegrationMapping: + def update_integration_mapping_slack_by_id(self, integration_mapping_id: str, box_item: Optional[IntegrationMappingBoxItemSlack] = None, options: Optional[IntegrationMappingSlackOptions] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> IntegrationMapping: """ Updates a [Slack integration mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack). diff --git a/box_sdk_gen/managers/memberships.py b/box_sdk_gen/managers/memberships.py index c357c27..3c3c88e 100644 --- a/box_sdk_gen/managers/memberships.py +++ b/box_sdk_gen/managers/memberships.py @@ -54,18 +54,10 @@ class CreateGroupMembershipRoleArg(str, Enum): MEMBER = 'member' ADMIN = 'admin' -class CreateGroupMembershipConfigurablePermissionsArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - class UpdateGroupMembershipByIdRoleArg(str, Enum): MEMBER = 'member' ADMIN = 'admin' -class UpdateGroupMembershipByIdConfigurablePermissionsArg(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - class MembershipsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -126,7 +118,7 @@ def get_group_memberships(self, group_id: str, limit: Optional[int] = None, offs headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/groups/', group_id, '/memberships']), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return GroupMemberships.from_dict(json.loads(response.text)) - def create_group_membership(self, user: CreateGroupMembershipUserArg, group: CreateGroupMembershipGroupArg, role: Optional[CreateGroupMembershipRoleArg] = None, configurable_permissions: Optional[CreateGroupMembershipConfigurablePermissionsArg] = None, fields: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> GroupMembership: + def create_group_membership(self, user: CreateGroupMembershipUserArg, group: CreateGroupMembershipGroupArg, role: Optional[CreateGroupMembershipRoleArg] = None, configurable_permissions: Optional[Dict[str, bool]] = None, fields: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> GroupMembership: """ Creates a group membership. Only users with @@ -146,7 +138,7 @@ def create_group_membership(self, user: CreateGroupMembershipUserArg, group: Cre Specifying a value of "null" for this object will disable all configurable permissions. Specifying permissions will set them accordingly, omitted permissions will be enabled by default. - :type configurable_permissions: Optional[CreateGroupMembershipConfigurablePermissionsArg], optional + :type configurable_permissions: Optional[Dict[str, bool]], optional :param fields: A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response. @@ -196,7 +188,7 @@ def get_group_membership_by_id(self, group_membership_id: str, fields: Optional[ headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/group_memberships/', group_membership_id]), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return GroupMembership.from_dict(json.loads(response.text)) - def update_group_membership_by_id(self, group_membership_id: str, role: Optional[UpdateGroupMembershipByIdRoleArg] = None, configurable_permissions: Optional[UpdateGroupMembershipByIdConfigurablePermissionsArg] = None, fields: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> GroupMembership: + def update_group_membership_by_id(self, group_membership_id: str, role: Optional[UpdateGroupMembershipByIdRoleArg] = None, configurable_permissions: Optional[Dict[str, bool]] = None, fields: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> GroupMembership: """ Updates a user's group membership. Only admins of this @@ -218,7 +210,7 @@ def update_group_membership_by_id(self, group_membership_id: str, role: Optional Specifying a value of "null" for this object will disable all configurable permissions. Specifying permissions will set them accordingly, omitted permissions will be enabled by default. - :type configurable_permissions: Optional[UpdateGroupMembershipByIdConfigurablePermissionsArg], optional + :type configurable_permissions: Optional[Dict[str, bool]], optional :param fields: A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response. diff --git a/box_sdk_gen/managers/metadata_cascade_policies.py b/box_sdk_gen/managers/metadata_cascade_policies.py index 2de653d..b02a1a4 100644 --- a/box_sdk_gen/managers/metadata_cascade_policies.py +++ b/box_sdk_gen/managers/metadata_cascade_policies.py @@ -118,7 +118,7 @@ def create_metadata_cascade_policy(self, folder_id: str, scope: CreateMetadataCa """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject(folder_id=folder_id, scope=scope, template_key=template_key) + request_body: BaseObject = BaseObject(folder_id=folder_id, scope=scope, templateKey=template_key) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_cascade_policies']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return MetadataCascadePolicy.from_dict(json.loads(response.text)) diff --git a/box_sdk_gen/managers/metadata_templates.py b/box_sdk_gen/managers/metadata_templates.py index 065e257..f4f2350 100644 --- a/box_sdk_gen/managers/metadata_templates.py +++ b/box_sdk_gen/managers/metadata_templates.py @@ -4,11 +4,11 @@ from typing import Dict -import json - from typing import List -from typing import Union +from box_sdk_gen.base_object import BaseObject + +import json from box_sdk_gen.base_object import BaseObject @@ -38,10 +38,121 @@ class GetMetadataTemplateSchemaScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' +class UpdateMetadataTemplateSchemaScopeArg(str, Enum): + GLOBAL = 'global' + ENTERPRISE = 'enterprise' + +class UpdateMetadataTemplateSchemaRequestBodyArgOpField(str, Enum): + EDITTEMPLATE = 'editTemplate' + ADDFIELD = 'addField' + REORDERFIELDS = 'reorderFields' + ADDENUMOPTION = 'addEnumOption' + REORDERENUMOPTIONS = 'reorderEnumOptions' + REORDERMULTISELECTOPTIONS = 'reorderMultiSelectOptions' + ADDMULTISELECTOPTION = 'addMultiSelectOption' + EDITFIELD = 'editField' + REMOVEFIELD = 'removeField' + EDITENUMOPTION = 'editEnumOption' + REMOVEENUMOPTION = 'removeEnumOption' + EDITMULTISELECTOPTION = 'editMultiSelectOption' + REMOVEMULTISELECTOPTION = 'removeMultiSelectOption' + +class UpdateMetadataTemplateSchemaRequestBodyArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'field_key': 'fieldKey', 'field_keys': 'fieldKeys', 'enum_option_key': 'enumOptionKey', 'enum_option_keys': 'enumOptionKeys', 'multi_select_option_key': 'multiSelectOptionKey', 'multi_select_option_keys': 'multiSelectOptionKeys', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'fieldKey': 'field_key', 'fieldKeys': 'field_keys', 'enumOptionKey': 'enum_option_key', 'enumOptionKeys': 'enum_option_keys', 'multiSelectOptionKey': 'multi_select_option_key', 'multiSelectOptionKeys': 'multi_select_option_keys', **BaseObject._json_to_fields_mapping} + def __init__(self, op: UpdateMetadataTemplateSchemaRequestBodyArgOpField, data: Optional[Dict[str, str]] = None, field_key: Optional[str] = None, field_keys: Optional[List[str]] = None, enum_option_key: Optional[str] = None, enum_option_keys: Optional[List[str]] = None, multi_select_option_key: Optional[str] = None, multi_select_option_keys: Optional[List[str]] = None, **kwargs): + """ + :param op: The type of change to perform on the template. Some + of these are hazardous as they will change existing templates. + :type op: UpdateMetadataTemplateSchemaRequestBodyArgOpField + :param data: The data for the operation. This will vary depending on the + operation being performed. + :type data: Optional[Dict[str, str]], optional + :param field_key: For operations that affect a single field this defines the key of + the field that is affected. + :type field_key: Optional[str], optional + :param field_keys: For operations that affect multiple fields this defines the keys + of the fields that are affected. + :type field_keys: Optional[List[str]], optional + :param enum_option_key: For operations that affect a single `enum` option this defines + the key of the option that is affected. + :type enum_option_key: Optional[str], optional + :param enum_option_keys: For operations that affect multiple `enum` options this defines + the keys of the options that are affected. + :type enum_option_keys: Optional[List[str]], optional + :param multi_select_option_key: For operations that affect a single multi select option this + defines the key of the option that is affected. + :type multi_select_option_key: Optional[str], optional + :param multi_select_option_keys: For operations that affect multiple multi select options this + defines the keys of the options that are affected. + :type multi_select_option_keys: Optional[List[str]], optional + """ + super().__init__(**kwargs) + self.op = op + self.data = data + self.field_key = field_key + self.field_keys = field_keys + self.enum_option_key = enum_option_key + self.enum_option_keys = enum_option_keys + self.multi_select_option_key = multi_select_option_key + self.multi_select_option_keys = multi_select_option_keys + class DeleteMetadataTemplateSchemaScopeArg(str, Enum): GLOBAL = 'global' ENTERPRISE = 'enterprise' +class CreateMetadataTemplateSchemaFieldsArgTypeField(str, Enum): + STRING = 'string' + FLOAT = 'float' + DATE = 'date' + ENUM = 'enum' + MULTISELECT = 'multiSelect' + +class CreateMetadataTemplateSchemaFieldsArgOptionsField(BaseObject): + def __init__(self, key: str, **kwargs): + """ + :param key: The text value of the option. This represents both the display name of the + option and the internal key used when updating templates. + :type key: str + """ + super().__init__(**kwargs) + self.key = key + +class CreateMetadataTemplateSchemaFieldsArg(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'display_name': 'displayName', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'displayName': 'display_name', **BaseObject._json_to_fields_mapping} + def __init__(self, type: CreateMetadataTemplateSchemaFieldsArgTypeField, key: str, display_name: str, description: Optional[str] = None, hidden: Optional[bool] = None, options: Optional[List[CreateMetadataTemplateSchemaFieldsArgOptionsField]] = None, **kwargs): + """ + :param type: The type of field. The basic fields are a `string` field for text, a + `float` field for numbers, and a `date` fields to present the user with a + date-time picker. + Additionally, metadata templates support an `enum` field for a basic list + of items, and ` multiSelect` field for a similar list of items where the + user can select more than one value. + :type type: CreateMetadataTemplateSchemaFieldsArgTypeField + :param key: A unique identifier for the field. The identifier must + be unique within the template to which it belongs. + :type key: str + :param display_name: The display name of the field as it is shown to the user in the web and + mobile apps. + :type display_name: str + :param description: A description of the field. This is not shown to the user. + :type description: Optional[str], optional + :param hidden: Whether this field is hidden in the UI for the user and can only be set + through the API instead. + :type hidden: Optional[bool], optional + :param options: A list of options for this field. This is used in combination with the + `enum` and `multiSelect` field types. + :type options: Optional[List[CreateMetadataTemplateSchemaFieldsArgOptionsField]], optional + """ + super().__init__(**kwargs) + self.type = type + self.key = key + self.display_name = display_name + self.description = description + self.hidden = hidden + self.options = options + class MetadataTemplatesManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -86,6 +197,37 @@ def get_metadata_template_schema(self, scope: GetMetadataTemplateSchemaScopeArg, headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/', scope, '/', template_key, '/schema']), FetchOptions(method='GET', headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return MetadataTemplate.from_dict(json.loads(response.text)) + def update_metadata_template_schema(self, scope: UpdateMetadataTemplateSchemaScopeArg, template_key: str, request_body: List[UpdateMetadataTemplateSchemaRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> MetadataTemplate: + """ + Updates a metadata template. + + The metadata template can only be updated if the template + + + already exists. + + + The update is applied atomically. If any errors occur during the + + + application of the operations, the metadata template will not be changed. + + :param scope: The scope of the metadata template + Example: "global" + :type scope: UpdateMetadataTemplateSchemaScopeArg + :param template_key: The name of the metadata template + Example: "properties" + :type template_key: str + :param request_body: Request body of updateMetadataTemplateSchema method + :type request_body: List[UpdateMetadataTemplateSchemaRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/', scope, '/', template_key, '/schema']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return MetadataTemplate.from_dict(json.loads(response.text)) def delete_metadata_template_schema(self, scope: DeleteMetadataTemplateSchemaScopeArg, template_key: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Delete a metadata template and its instances. @@ -162,7 +304,7 @@ def get_metadata_template_enterprise(self, marker: Optional[str] = None, limit: headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/enterprise']), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return MetadataTemplates.from_dict(json.loads(response.text)) - def create_metadata_template_schema(self, scope: str, display_name: str, template_key: Optional[str] = None, hidden: Optional[bool] = None, fields: Optional[List] = None, copy_instance_on_item_copy: Optional[bool] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> MetadataTemplate: + def create_metadata_template_schema(self, scope: str, display_name: str, template_key: Optional[str] = None, hidden: Optional[bool] = None, fields: Optional[List[CreateMetadataTemplateSchemaFieldsArg]] = None, copy_instance_on_item_copy: Optional[bool] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> MetadataTemplate: """ Creates a new metadata template that can be applied to @@ -188,7 +330,7 @@ def create_metadata_template_schema(self, scope: str, display_name: str, templat :param fields: An ordered list of template fields which are part of the template. Each field can be a regular text field, date field, number field, as well as a single or multi-select list. - :type fields: Optional[List], optional + :type fields: Optional[List[CreateMetadataTemplateSchemaFieldsArg]], optional :param copy_instance_on_item_copy: Whether or not to copy any metadata attached to a file or folder when it is copied. By default, metadata is not copied along with a file or folder when it is copied. @@ -198,7 +340,7 @@ def create_metadata_template_schema(self, scope: str, display_name: str, templat """ if extra_headers is None: extra_headers = {} - request_body: BaseObject = BaseObject(scope=scope, template_key=template_key, display_name=display_name, hidden=hidden, fields=fields, copy_instance_on_item_copy=copy_instance_on_item_copy) + request_body: BaseObject = BaseObject(scope=scope, templateKey=template_key, displayName=display_name, hidden=hidden, fields=fields, copyInstanceOnItemCopy=copy_instance_on_item_copy) headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/metadata_templates/schema']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return MetadataTemplate.from_dict(json.loads(response.text)) \ No newline at end of file diff --git a/box_sdk_gen/managers/retention_policy_assignments.py b/box_sdk_gen/managers/retention_policy_assignments.py index 499a2cb..9cd5547 100644 --- a/box_sdk_gen/managers/retention_policy_assignments.py +++ b/box_sdk_gen/managers/retention_policy_assignments.py @@ -60,6 +60,19 @@ def __init__(self, type: CreateRetentionPolicyAssignmentAssignToArgTypeField, id self.type = type self.id = id +class CreateRetentionPolicyAssignmentFilterFieldsArg(BaseObject): + def __init__(self, field: Optional[str] = None, value: Optional[str] = None, **kwargs): + """ + :param field: The metadata attribute key id. + :type field: Optional[str], optional + :param value: The metadata attribute field id. For value, only + enum and multiselect types are supported. + :type value: Optional[str], optional + """ + super().__init__(**kwargs) + self.field = field + self.value = value + class RetentionPolicyAssignmentsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -98,7 +111,7 @@ def get_retention_policy_assignments(self, retention_policy_id: str, type: Optio headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/retention_policies/', retention_policy_id, '/assignments']), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return RetentionPolicyAssignments.from_dict(json.loads(response.text)) - def create_retention_policy_assignment(self, policy_id: str, assign_to: CreateRetentionPolicyAssignmentAssignToArg, filter_fields: Optional[List] = None, start_date_field: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> RetentionPolicyAssignment: + def create_retention_policy_assignment(self, policy_id: str, assign_to: CreateRetentionPolicyAssignmentAssignToArg, filter_fields: Optional[List[CreateRetentionPolicyAssignmentFilterFieldsArg]] = None, start_date_field: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> RetentionPolicyAssignment: """ Assigns a retention policy to an item. :param policy_id: The ID of the retention policy to assign @@ -109,7 +122,7 @@ def create_retention_policy_assignment(self, policy_id: str, assign_to: CreateRe then optionally add the `filter_fields` parameter which will require an array of objects with a field entry and a value entry. Currently only one object of `field` and `value` is supported. - :type filter_fields: Optional[List], optional + :type filter_fields: Optional[List[CreateRetentionPolicyAssignmentFilterFieldsArg]], optional :param start_date_field: The date the retention policy assignment begins. If the `assigned_to` type is `metadata_template`, this field can be a date field's metadata attribute key id. diff --git a/box_sdk_gen/managers/search.py b/box_sdk_gen/managers/search.py index b2d090e..5fbd3e1 100644 --- a/box_sdk_gen/managers/search.py +++ b/box_sdk_gen/managers/search.py @@ -1,15 +1,13 @@ -from box_sdk_gen.base_object import BaseObject - from enum import Enum from typing import Optional -from typing import List - -from typing import Union +from box_sdk_gen.base_object import BaseObject from typing import Dict +from typing import List + import json from box_sdk_gen.schemas import MetadataQueryResults @@ -42,9 +40,25 @@ from box_sdk_gen.fetch import FetchResponse -class CreateMetadataQueryExecuteReadQueryParamsArg(BaseObject): - def __init__(self, **kwargs): +class CreateMetadataQueryExecuteReadOrderByArgDirectionField(str, Enum): + ASC = 'ASC' + DESC = 'DESC' + +class CreateMetadataQueryExecuteReadOrderByArg(BaseObject): + def __init__(self, field_key: Optional[str] = None, direction: Optional[CreateMetadataQueryExecuteReadOrderByArgDirectionField] = None, **kwargs): + """ + :param field_key: The metadata template field to order by. + The `field_key` represents the `key` value of a field from the + metadata template being searched for. + :type field_key: Optional[str], optional + :param direction: The direction to order by, either ascending or descending. + The `ordering` direction must be the same for each item in the + array. + :type direction: Optional[CreateMetadataQueryExecuteReadOrderByArgDirectionField], optional + """ super().__init__(**kwargs) + self.field_key = field_key + self.direction = direction class GetMetadataQueryIndicesScopeArg(str, Enum): GLOBAL = 'global' @@ -76,7 +90,7 @@ class SearchManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth self.network_session = network_session - def create_metadata_query_execute_read(self, from_: str, ancestor_folder_id: str, query: Optional[str] = None, query_params: Optional[CreateMetadataQueryExecuteReadQueryParamsArg] = None, order_by: Optional[List] = None, limit: Optional[int] = None, marker: Optional[str] = None, fields: Optional[List[str]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> MetadataQueryResults: + def create_metadata_query_execute_read(self, from_: str, ancestor_folder_id: str, query: Optional[str] = None, query_params: Optional[Dict[str, str]] = None, order_by: Optional[List[CreateMetadataQueryExecuteReadOrderByArg]] = None, limit: Optional[int] = None, marker: Optional[str] = None, fields: Optional[List[str]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> MetadataQueryResults: """ Create a search using SQL-like syntax to return items that match specific @@ -111,11 +125,11 @@ def create_metadata_query_execute_read(self, from_: str, ancestor_folder_id: str :param query_params: Set of arguments corresponding to the parameters specified in the `query`. The type of each parameter used in the `query_params` must match the type of the corresponding metadata template field. - :type query_params: Optional[CreateMetadataQueryExecuteReadQueryParamsArg], optional + :type query_params: Optional[Dict[str, str]], optional :param order_by: A list of template fields and directions to sort the metadata query results by. The ordering `direction` must be the same for each item in the array. - :type order_by: Optional[List], optional + :type order_by: Optional[List[CreateMetadataQueryExecuteReadOrderByArg]], optional :param limit: A value between 0 and 100 that indicates the maximum number of results to return for a single request. This only specifies a maximum boundary and will not guarantee the minimum number of results diff --git a/box_sdk_gen/managers/skills.py b/box_sdk_gen/managers/skills.py index ff07115..c6c4049 100644 --- a/box_sdk_gen/managers/skills.py +++ b/box_sdk_gen/managers/skills.py @@ -2,12 +2,12 @@ from typing import Optional -from typing import List - from typing import Union from box_sdk_gen.base_object import BaseObject +from typing import List + from typing import Dict import json @@ -42,6 +42,24 @@ from box_sdk_gen.fetch import FetchResponse +class UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArgOpField(str, Enum): + REPLACE = 'replace' + +class UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArg(BaseObject): + def __init__(self, op: Optional[UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArgOpField] = None, path: Optional[str] = None, value: Optional[Union[KeywordSkillCard, TimelineSkillCard, TranscriptSkillCard, StatusSkillCard]] = None, **kwargs): + """ + :param op: `replace` + :type op: Optional[UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArgOpField], optional + :param path: The JSON Path that represents the card to replace. In most cases + this will be in the format `/cards/{index}` where `index` is the + zero-indexed position of the card in the list of cards. + :type path: Optional[str], optional + """ + super().__init__(**kwargs) + self.op = op + self.path = path + self.value = value + class UpdateSkillInvocationByIdStatusArg(str, Enum): INVOKED = 'invoked' PROCESSING = 'processing' @@ -145,6 +163,27 @@ def create_file_metadata_global_box_skills_card(self, file_id: str, cards: List[ headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/global/boxSkillsCards']), FetchOptions(method='POST', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json', response_format='json', auth=self.auth, network_session=self.network_session)) return SkillCardsMetadata.from_dict(json.loads(response.text)) + def update_file_metadata_global_box_skills_card(self, file_id: str, request_body: List[UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> SkillCardsMetadata: + """ + Updates one or more Box Skills metadata cards to a file. + :param file_id: The unique identifier that represents a file. + The ID for any file can be determined + by visiting a file in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/files/123` + the `file_id` is `123`. + Example: "12345" + :type file_id: str + :param request_body: Request body of updateFileMetadataGlobalBoxSkillsCard method + :type request_body: List[UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArg] + :param extra_headers: Extra headers that will be included in the HTTP request. + :type extra_headers: Optional[Dict[str, Optional[str]]], optional + """ + if extra_headers is None: + extra_headers = {} + headers_map: Dict[str, str] = prepare_params({**extra_headers}) + response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/files/', file_id, '/metadata/global/boxSkillsCards']), FetchOptions(method='PUT', headers=headers_map, body=json.dumps(request_body.to_dict()), content_type='application/json-patch+json', response_format='json', auth=self.auth, network_session=self.network_session)) + return SkillCardsMetadata.from_dict(json.loads(response.text)) def delete_file_metadata_global_box_skills_card(self, file_id: str, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Removes any Box Skills cards metadata from a file. diff --git a/box_sdk_gen/managers/uploads.py b/box_sdk_gen/managers/uploads.py index 84708ae..6908f51 100644 --- a/box_sdk_gen/managers/uploads.py +++ b/box_sdk_gen/managers/uploads.py @@ -165,7 +165,7 @@ def upload_file_version(self, file_id: str, attributes: UploadFileVersionAttribu request_body: BaseObject = BaseObject(attributes=attributes, file=file, file_file_name=file_file_name, 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}) - response: FetchResponse = fetch(''.join(['https://upload.box.com/api/2.0/files/', file_id, '/content']), FetchOptions(method='POST', params=query_params_map, headers=headers_map, multipart_data=[MultipartItem(part_name='attributes', body=json.dumps(request_body.attributes.to_dict())), MultipartItem(part_name='file', file_stream=request_body.file, content_type=request_body.file_content_type, file_name=request_body.file_file_name)], content_type='multipart/form-data', response_format='json', auth=self.auth, network_session=self.network_session)) + response: FetchResponse = fetch(''.join(['https://upload.box.com/api/2.0/files/', file_id, '/content']), FetchOptions(method='POST', params=query_params_map, headers=headers_map, multipart_data=[MultipartItem(part_name='attributes', body=json.dumps(request_body.attributes.to_dict())), MultipartItem(part_name='file', file_stream=request_body.file, file_name=request_body.file_file_name, content_type=request_body.file_content_type)], content_type='multipart/form-data', response_format='json', auth=self.auth, network_session=self.network_session)) return Files.from_dict(json.loads(response.text)) def upload_file(self, attributes: UploadFileAttributesArg, file: ByteStream, file_file_name: Optional[str] = None, file_content_type: Optional[str] = None, fields: Optional[str] = None, content_md_5: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Files: """ @@ -226,7 +226,7 @@ def upload_file(self, attributes: UploadFileAttributesArg, file: ByteStream, fil request_body: BaseObject = BaseObject(attributes=attributes, file=file, file_file_name=file_file_name, 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}) - response: FetchResponse = fetch(''.join(['https://upload.box.com/api/2.0/files/content']), FetchOptions(method='POST', params=query_params_map, headers=headers_map, multipart_data=[MultipartItem(part_name='attributes', body=json.dumps(request_body.attributes.to_dict())), MultipartItem(part_name='file', file_stream=request_body.file, content_type=request_body.file_content_type, file_name=request_body.file_file_name)], content_type='multipart/form-data', response_format='json', auth=self.auth, network_session=self.network_session)) + response: FetchResponse = fetch(''.join(['https://upload.box.com/api/2.0/files/content']), FetchOptions(method='POST', params=query_params_map, headers=headers_map, multipart_data=[MultipartItem(part_name='attributes', body=json.dumps(request_body.attributes.to_dict())), MultipartItem(part_name='file', file_stream=request_body.file, file_name=request_body.file_file_name, content_type=request_body.file_content_type)], content_type='multipart/form-data', response_format='json', auth=self.auth, network_session=self.network_session)) return Files.from_dict(json.loads(response.text)) def preflight_file_upload(self, name: Optional[str] = None, size: Optional[int] = None, parent: Optional[PreflightFileUploadParentArg] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> UploadUrl: """ diff --git a/box_sdk_gen/managers/webhooks.py b/box_sdk_gen/managers/webhooks.py index 79143d3..1886a2f 100644 --- a/box_sdk_gen/managers/webhooks.py +++ b/box_sdk_gen/managers/webhooks.py @@ -10,8 +10,6 @@ from typing import List -from typing import Union - from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Webhooks @@ -52,6 +50,48 @@ def __init__(self, id: Optional[str] = None, type: Optional[CreateWebhookTargetA self.id = id self.type = type +class CreateWebhookTriggersArg(str, Enum): + FILE_UPLOADED = 'FILE.UPLOADED' + FILE_PREVIEWED = 'FILE.PREVIEWED' + FILE_DOWNLOADED = 'FILE.DOWNLOADED' + FILE_TRASHED = 'FILE.TRASHED' + FILE_DELETED = 'FILE.DELETED' + FILE_RESTORED = 'FILE.RESTORED' + FILE_COPIED = 'FILE.COPIED' + FILE_MOVED = 'FILE.MOVED' + FILE_LOCKED = 'FILE.LOCKED' + FILE_UNLOCKED = 'FILE.UNLOCKED' + FILE_RENAMED = 'FILE.RENAMED' + COMMENT_CREATED = 'COMMENT.CREATED' + COMMENT_UPDATED = 'COMMENT.UPDATED' + COMMENT_DELETED = 'COMMENT.DELETED' + TASK_ASSIGNMENT_CREATED = 'TASK_ASSIGNMENT.CREATED' + TASK_ASSIGNMENT_UPDATED = 'TASK_ASSIGNMENT.UPDATED' + METADATA_INSTANCE_CREATED = 'METADATA_INSTANCE.CREATED' + METADATA_INSTANCE_UPDATED = 'METADATA_INSTANCE.UPDATED' + METADATA_INSTANCE_DELETED = 'METADATA_INSTANCE.DELETED' + FOLDER_CREATED = 'FOLDER.CREATED' + FOLDER_RENAMED = 'FOLDER.RENAMED' + FOLDER_DOWNLOADED = 'FOLDER.DOWNLOADED' + FOLDER_RESTORED = 'FOLDER.RESTORED' + FOLDER_DELETED = 'FOLDER.DELETED' + FOLDER_COPIED = 'FOLDER.COPIED' + FOLDER_MOVED = 'FOLDER.MOVED' + FOLDER_TRASHED = 'FOLDER.TRASHED' + WEBHOOK_DELETED = 'WEBHOOK.DELETED' + COLLABORATION_CREATED = 'COLLABORATION.CREATED' + COLLABORATION_ACCEPTED = 'COLLABORATION.ACCEPTED' + COLLABORATION_REJECTED = 'COLLABORATION.REJECTED' + COLLABORATION_REMOVED = 'COLLABORATION.REMOVED' + COLLABORATION_UPDATED = 'COLLABORATION.UPDATED' + SHARED_LINK_DELETED = 'SHARED_LINK.DELETED' + SHARED_LINK_CREATED = 'SHARED_LINK.CREATED' + SHARED_LINK_UPDATED = 'SHARED_LINK.UPDATED' + SIGN_REQUEST_COMPLETED = 'SIGN_REQUEST.COMPLETED' + SIGN_REQUEST_DECLINED = 'SIGN_REQUEST.DECLINED' + SIGN_REQUEST_EXPIRED = 'SIGN_REQUEST.EXPIRED' + SIGN_REQUEST_SIGNER_EMAIL_BOUNCED = 'SIGN_REQUEST.SIGNER_EMAIL_BOUNCED' + class UpdateWebhookByIdTargetArgTypeField(str, Enum): FILE = 'file' FOLDER = 'folder' @@ -68,6 +108,48 @@ def __init__(self, id: Optional[str] = None, type: Optional[UpdateWebhookByIdTar self.id = id self.type = type +class UpdateWebhookByIdTriggersArg(str, Enum): + FILE_UPLOADED = 'FILE.UPLOADED' + FILE_PREVIEWED = 'FILE.PREVIEWED' + FILE_DOWNLOADED = 'FILE.DOWNLOADED' + FILE_TRASHED = 'FILE.TRASHED' + FILE_DELETED = 'FILE.DELETED' + FILE_RESTORED = 'FILE.RESTORED' + FILE_COPIED = 'FILE.COPIED' + FILE_MOVED = 'FILE.MOVED' + FILE_LOCKED = 'FILE.LOCKED' + FILE_UNLOCKED = 'FILE.UNLOCKED' + FILE_RENAMED = 'FILE.RENAMED' + COMMENT_CREATED = 'COMMENT.CREATED' + COMMENT_UPDATED = 'COMMENT.UPDATED' + COMMENT_DELETED = 'COMMENT.DELETED' + TASK_ASSIGNMENT_CREATED = 'TASK_ASSIGNMENT.CREATED' + TASK_ASSIGNMENT_UPDATED = 'TASK_ASSIGNMENT.UPDATED' + METADATA_INSTANCE_CREATED = 'METADATA_INSTANCE.CREATED' + METADATA_INSTANCE_UPDATED = 'METADATA_INSTANCE.UPDATED' + METADATA_INSTANCE_DELETED = 'METADATA_INSTANCE.DELETED' + FOLDER_CREATED = 'FOLDER.CREATED' + FOLDER_RENAMED = 'FOLDER.RENAMED' + FOLDER_DOWNLOADED = 'FOLDER.DOWNLOADED' + FOLDER_RESTORED = 'FOLDER.RESTORED' + FOLDER_DELETED = 'FOLDER.DELETED' + FOLDER_COPIED = 'FOLDER.COPIED' + FOLDER_MOVED = 'FOLDER.MOVED' + FOLDER_TRASHED = 'FOLDER.TRASHED' + WEBHOOK_DELETED = 'WEBHOOK.DELETED' + COLLABORATION_CREATED = 'COLLABORATION.CREATED' + COLLABORATION_ACCEPTED = 'COLLABORATION.ACCEPTED' + COLLABORATION_REJECTED = 'COLLABORATION.REJECTED' + COLLABORATION_REMOVED = 'COLLABORATION.REMOVED' + COLLABORATION_UPDATED = 'COLLABORATION.UPDATED' + SHARED_LINK_DELETED = 'SHARED_LINK.DELETED' + SHARED_LINK_CREATED = 'SHARED_LINK.CREATED' + SHARED_LINK_UPDATED = 'SHARED_LINK.UPDATED' + SIGN_REQUEST_COMPLETED = 'SIGN_REQUEST.COMPLETED' + SIGN_REQUEST_DECLINED = 'SIGN_REQUEST.DECLINED' + SIGN_REQUEST_EXPIRED = 'SIGN_REQUEST.EXPIRED' + SIGN_REQUEST_SIGNER_EMAIL_BOUNCED = 'SIGN_REQUEST.SIGNER_EMAIL_BOUNCED' + class WebhooksManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -102,7 +184,7 @@ def get_webhooks(self, marker: Optional[str] = None, limit: Optional[int] = None headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/webhooks']), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return Webhooks.from_dict(json.loads(response.text)) - def create_webhook(self, target: CreateWebhookTargetArg, address: str, triggers: List[Union[str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str]], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Webhook: + def create_webhook(self, target: CreateWebhookTargetArg, address: str, triggers: List[CreateWebhookTriggersArg], extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Webhook: """ Creates a webhook. :param target: The item that will trigger the webhook @@ -111,7 +193,7 @@ def create_webhook(self, target: CreateWebhookTargetArg, address: str, triggers: :type address: str :param triggers: An array of event names that this webhook is to be triggered for - :type triggers: List[Union[str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str]] + :type triggers: List[CreateWebhookTriggersArg] :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ @@ -135,7 +217,7 @@ def get_webhook_by_id(self, webhook_id: str, extra_headers: Optional[Dict[str, O headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/webhooks/', webhook_id]), FetchOptions(method='GET', headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return Webhook.from_dict(json.loads(response.text)) - def update_webhook_by_id(self, webhook_id: str, target: Optional[UpdateWebhookByIdTargetArg] = None, address: Optional[str] = None, triggers: Optional[List[Union[str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str]]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Webhook: + def update_webhook_by_id(self, webhook_id: str, target: Optional[UpdateWebhookByIdTargetArg] = None, address: Optional[str] = None, triggers: Optional[List[UpdateWebhookByIdTriggersArg]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> Webhook: """ Updates a webhook. :param webhook_id: The ID of the webhook. @@ -147,7 +229,7 @@ def update_webhook_by_id(self, webhook_id: str, target: Optional[UpdateWebhookBy :type address: Optional[str], optional :param triggers: An array of event names that this webhook is to be triggered for - :type triggers: Optional[List[Union[str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str]]], optional + :type triggers: Optional[List[UpdateWebhookByIdTriggersArg]], optional :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/workflows.py b/box_sdk_gen/managers/workflows.py index 0af9729..cd7bae7 100644 --- a/box_sdk_gen/managers/workflows.py +++ b/box_sdk_gen/managers/workflows.py @@ -10,8 +10,6 @@ from typing import List -from typing import Union - from box_sdk_gen.base_object import BaseObject from box_sdk_gen.schemas import Workflows @@ -49,6 +47,21 @@ def __init__(self, type: Optional[str] = None, id: Optional[str] = None, **kwarg self.type = type self.id = id +class CreateWorkflowStartFilesArgTypeField(str, Enum): + FILE = 'file' + +class CreateWorkflowStartFilesArg(BaseObject): + def __init__(self, type: Optional[CreateWorkflowStartFilesArgTypeField] = None, id: Optional[str] = None, **kwargs): + """ + :param type: The type of the file object + :type type: Optional[CreateWorkflowStartFilesArgTypeField], optional + :param id: The id of the file + :type id: Optional[str], optional + """ + super().__init__(**kwargs) + self.type = type + self.id = id + class CreateWorkflowStartFolderArgTypeField(str, Enum): FOLDER = 'folder' @@ -64,6 +77,26 @@ def __init__(self, type: Optional[CreateWorkflowStartFolderArgTypeField] = None, self.type = type self.id = id +class CreateWorkflowStartOutcomesArgTypeField(str, Enum): + OUTCOME = 'outcome' + +class CreateWorkflowStartOutcomesArg(BaseObject): + def __init__(self, id: Optional[str] = None, type: Optional[CreateWorkflowStartOutcomesArgTypeField] = None, parameter: Optional[str] = None, **kwargs): + """ + :param id: The id of the outcome + :type id: Optional[str], optional + :param type: The type of the outcome object + :type type: Optional[CreateWorkflowStartOutcomesArgTypeField], optional + :param parameter: This is a placeholder example for various objects that + can be passed in - refer to the guides section to find + out more information. + :type parameter: Optional[str], optional + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.parameter = parameter + class WorkflowsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth @@ -106,7 +139,7 @@ def get_workflows(self, folder_id: str, trigger_type: Optional[str] = None, limi headers_map: Dict[str, str] = prepare_params({**extra_headers}) response: FetchResponse = fetch(''.join(['https://api.box.com/2.0/workflows']), FetchOptions(method='GET', params=query_params_map, headers=headers_map, response_format='json', auth=self.auth, network_session=self.network_session)) return Workflows.from_dict(json.loads(response.text)) - def create_workflow_start(self, workflow_id: str, flow: CreateWorkflowStartFlowArg, files: List, folder: CreateWorkflowStartFolderArg, type: Optional[CreateWorkflowStartTypeArg] = None, outcomes: Optional[List] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: + def create_workflow_start(self, workflow_id: str, flow: CreateWorkflowStartFlowArg, files: List[CreateWorkflowStartFilesArg], folder: CreateWorkflowStartFolderArg, type: Optional[CreateWorkflowStartTypeArg] = None, outcomes: Optional[List[CreateWorkflowStartOutcomesArg]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> None: """ Initiates a flow with a trigger type of `WORKFLOW_MANUAL_START`. @@ -122,13 +155,13 @@ def create_workflow_start(self, workflow_id: str, flow: CreateWorkflowStartFlowA :type flow: CreateWorkflowStartFlowArg :param files: The array of files for which the workflow should start. All files must be in the workflow's configured folder. - :type files: List + :type files: List[CreateWorkflowStartFilesArg] :param folder: The folder object for which the workflow is configured. :type folder: CreateWorkflowStartFolderArg :param type: The type of the parameters object :type type: Optional[CreateWorkflowStartTypeArg], optional :param outcomes: A list of outcomes required to be configured at start time. - :type outcomes: Optional[List], optional + :type outcomes: Optional[List[CreateWorkflowStartOutcomesArg]], optional :param extra_headers: Extra headers that will be included in the HTTP request. :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/zip_downloads.py b/box_sdk_gen/managers/zip_downloads.py index f8c8508..cc33baf 100644 --- a/box_sdk_gen/managers/zip_downloads.py +++ b/box_sdk_gen/managers/zip_downloads.py @@ -1,9 +1,11 @@ +from enum import Enum + +from box_sdk_gen.base_object import BaseObject + from typing import Optional from typing import List -from typing import Union - from typing import Dict import json @@ -32,11 +34,28 @@ from box_sdk_gen.fetch import FetchResponse +class CreateZipDownloadItemsArgTypeField(str, Enum): + FILE = 'file' + FOLDER_ = 'folder.' + +class CreateZipDownloadItemsArg(BaseObject): + def __init__(self, type: CreateZipDownloadItemsArgTypeField, id: str, **kwargs): + """ + :param type: The type of the item to add to the archive. + :type type: CreateZipDownloadItemsArgTypeField + :param id: The identifier of the item to add to the archive. When this item is + a folder then this can not be the root folder with ID `0`. + :type id: str + """ + super().__init__(**kwargs) + self.type = type + self.id = id + class ZipDownloadsManager: def __init__(self, auth: Optional[Authentication] = None, network_session: Optional[NetworkSession] = None): self.auth = auth self.network_session = network_session - def create_zip_download(self, items: List, download_file_name: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ZipDownload: + def create_zip_download(self, items: List[CreateZipDownloadItemsArg], download_file_name: Optional[str] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None) -> ZipDownload: """ Creates a request to download multiple files and folders as a single `zip` @@ -80,7 +99,7 @@ def create_zip_download(self, items: List, download_file_name: Optional[str] = N :param items: A list of items to add to the `zip` archive. These can be folders or files. - :type items: List + :type items: List[CreateZipDownloadItemsArg] :param download_file_name: The optional name of the `zip` archive. This name will be appended by the `.zip` file extension, for example `January Financials.zip`. :type download_file_name: Optional[str], optional diff --git a/box_sdk_gen/schemas.py b/box_sdk_gen/schemas.py index 6586b6f..e9c3785 100644 --- a/box_sdk_gen/schemas.py +++ b/box_sdk_gen/schemas.py @@ -176,10 +176,6 @@ def __init__(self, items: List[ZipDownloadRequestItemsField], download_file_name self.items = items self.download_file_name = download_file_name -class MetadataQueryQueryParamsField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - class MetadataQueryOrderByFieldDirectionField(str, Enum): ASC = 'ASC' DESC = 'DESC' @@ -203,7 +199,7 @@ def __init__(self, field_key: Optional[str] = None, direction: Optional[Metadata class MetadataQuery(BaseObject): _fields_to_json_mapping: Dict[str, str] = {'from_': 'from', **BaseObject._fields_to_json_mapping} _json_to_fields_mapping: Dict[str, str] = {'from': 'from_', **BaseObject._json_to_fields_mapping} - def __init__(self, from_: str, ancestor_folder_id: str, query: Optional[str] = None, query_params: Optional[MetadataQueryQueryParamsField] = None, order_by: Optional[List[MetadataQueryOrderByField]] = None, limit: Optional[int] = None, marker: Optional[str] = None, fields: Optional[List[str]] = None, **kwargs): + def __init__(self, from_: str, ancestor_folder_id: str, query: Optional[str] = None, query_params: Optional[Dict[str, str]] = None, order_by: Optional[List[MetadataQueryOrderByField]] = None, limit: Optional[int] = None, marker: Optional[str] = None, fields: Optional[List[str]] = None, **kwargs): """ :param from_: Specifies the template used in the query. Must be in the form `scope.templateKey`. Not all templates can be used in this field, @@ -225,7 +221,7 @@ def __init__(self, from_: str, ancestor_folder_id: str, query: Optional[str] = N :param query_params: Set of arguments corresponding to the parameters specified in the `query`. The type of each parameter used in the `query_params` must match the type of the corresponding metadata template field. - :type query_params: Optional[MetadataQueryQueryParamsField], optional + :type query_params: Optional[Dict[str, str]], optional :param order_by: A list of template fields and directions to sort the metadata query results by. The ordering `direction` must be the same for each item in the array. @@ -370,25 +366,6 @@ def __init__(self, folder: FileRequestCopyRequestFolderField, title: Optional[st super().__init__(title=title, description=description, status=status, is_email_required=is_email_required, is_description_required=is_description_required, expires_at=expires_at, **kwargs) self.folder = folder -class IntegrationMappingSlackCreateRequestPartnerItemField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class IntegrationMappingSlackCreateRequestBoxItemField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class IntegrationMappingSlackCreateRequestOptionsField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class IntegrationMappingSlackCreateRequest(BaseObject): - def __init__(self, partner_item: IntegrationMappingSlackCreateRequestPartnerItemField, box_item: IntegrationMappingSlackCreateRequestBoxItemField, options: Optional[IntegrationMappingSlackCreateRequestOptionsField] = None, **kwargs): - super().__init__(**kwargs) - self.partner_item = partner_item - self.box_item = box_item - self.options = options - class ClientErrorTypeField(str, Enum): ERROR = 'error' @@ -1494,9 +1471,51 @@ def __init__(self, limit: Optional[int] = None, next_marker: Optional[int] = Non self.prev_marker = prev_marker self.entries = entries -class Metadata(BaseObject): - def __init__(self, **kwargs): +class MetadataBase(BaseObject): + _fields_to_json_mapping: Dict[str, str] = {'parent': '$parent', 'template': '$template', 'scope': '$scope', 'version': '$version', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'$parent': 'parent', '$template': 'template', '$scope': 'scope', '$version': 'version', **BaseObject._json_to_fields_mapping} + def __init__(self, parent: Optional[str] = None, template: Optional[str] = None, scope: Optional[str] = None, version: Optional[int] = None, **kwargs): + """ + :param parent: The identifier of the item that this metadata instance + has been attached to. This combines the `type` and the `id` + of the parent in the form `{type}_{id}`. + :type parent: Optional[str], optional + :param template: The name of the template + :type template: Optional[str], optional + :param scope: An ID for the scope in which this template + has been applied. This will be `enterprise_{enterprise_id}` for templates + defined for use in this enterprise, and `global` for general templates + that are available to all enterprises using Box. + :type scope: Optional[str], optional + :param version: The version of the metadata instance. This version starts at 0 and + increases every time a user-defined property is modified. + :type version: Optional[int], optional + """ super().__init__(**kwargs) + self.parent = parent + self.template = template + self.scope = scope + self.version = version + +class Metadata(MetadataBase): + def __init__(self, parent: Optional[str] = None, template: Optional[str] = None, scope: Optional[str] = None, version: Optional[int] = None, **kwargs): + """ + :param parent: The identifier of the item that this metadata instance + has been attached to. This combines the `type` and the `id` + of the parent in the form `{type}_{id}`. + :type parent: Optional[str], optional + :param template: The name of the template + :type template: Optional[str], optional + :param scope: An ID for the scope in which this template + has been applied. This will be `enterprise_{enterprise_id}` for templates + defined for use in this enterprise, and `global` for general templates + that are available to all enterprises using Box. + :type scope: Optional[str], optional + :param version: The version of the metadata instance. This version starts at 0 and + increases every time a user-defined property is modified. + :type version: Optional[int], optional + """ + super().__init__(parent=parent, template=template, scope=scope, version=version, **kwargs) class Metadatas(BaseObject): def __init__(self, entries: Optional[List[Metadata]] = None, limit: Optional[int] = None, **kwargs): @@ -1511,9 +1530,9 @@ def __init__(self, entries: Optional[List[Metadata]] = None, limit: Optional[int self.limit = limit class MetadataFull(Metadata): - _fields_to_json_mapping: Dict[str, str] = {'can_edit': '$canEdit', 'id': '$id', 'type': '$type', 'type_version': '$typeVersion', **Metadata._fields_to_json_mapping} - _json_to_fields_mapping: Dict[str, str] = {'$canEdit': 'can_edit', '$id': 'id', '$type': 'type', '$typeVersion': 'type_version', **Metadata._json_to_fields_mapping} - def __init__(self, can_edit: Optional[bool] = None, id: Optional[str] = None, type: Optional[str] = None, type_version: Optional[int] = None, **kwargs): + _fields_to_json_mapping: Dict[str, str] = {'can_edit': '$canEdit', 'id': '$id', 'type': '$type', 'type_version': '$typeVersion', 'extra_data': 'extraData', **Metadata._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'$canEdit': 'can_edit', '$id': 'id', '$type': 'type', '$typeVersion': 'type_version', 'extraData': 'extra_data', **Metadata._json_to_fields_mapping} + def __init__(self, can_edit: Optional[bool] = None, id: Optional[str] = None, type: Optional[str] = None, type_version: Optional[int] = None, extra_data: Optional[Dict[str, str]] = None, parent: Optional[str] = None, template: Optional[str] = None, scope: Optional[str] = None, version: Optional[int] = None, **kwargs): """ :param can_edit: Whether the user can edit this metadata instance. :type can_edit: Optional[bool], optional @@ -1527,18 +1546,6 @@ def __init__(self, can_edit: Optional[bool] = None, id: Optional[str] = None, ty internal system property and should not be used by a client application. :type type_version: Optional[int], optional - """ - super().__init__(**kwargs) - self.can_edit = can_edit - self.id = id - self.type = type - self.type_version = type_version - -class MetadataBase(BaseObject): - _fields_to_json_mapping: Dict[str, str] = {'parent': '$parent', 'template': '$template', 'scope': '$scope', 'version': '$version', **BaseObject._fields_to_json_mapping} - _json_to_fields_mapping: Dict[str, str] = {'$parent': 'parent', '$template': 'template', '$scope': 'scope', '$version': 'version', **BaseObject._json_to_fields_mapping} - def __init__(self, parent: Optional[str] = None, template: Optional[str] = None, scope: Optional[str] = None, version: Optional[int] = None, **kwargs): - """ :param parent: The identifier of the item that this metadata instance has been attached to. This combines the `type` and the `id` of the parent in the form `{type}_{id}`. @@ -1554,11 +1561,12 @@ def __init__(self, parent: Optional[str] = None, template: Optional[str] = None, increases every time a user-defined property is modified. :type version: Optional[int], optional """ - super().__init__(**kwargs) - self.parent = parent - self.template = template - self.scope = scope - self.version = version + super().__init__(parent=parent, template=template, scope=scope, version=version, **kwargs) + self.can_edit = can_edit + self.id = id + self.type = type + self.type_version = type_version + self.extra_data = extra_data class MetadataCascadePolicyTypeField(str, Enum): METADATA_CASCADE_POLICY = 'metadata_cascade_policy' @@ -1718,6 +1726,7 @@ class MetadataTemplateFieldsFieldTypeField(str, Enum): DATE = 'date' ENUM = 'enum' MULTISELECT = 'multiSelect' + INTEGER = 'integer' class MetadataTemplateFieldsFieldOptionsField(BaseObject): def __init__(self, key: str, id: Optional[str] = None, **kwargs): @@ -1743,6 +1752,9 @@ def __init__(self, type: MetadataTemplateFieldsFieldTypeField, key: str, display Additionally, metadata templates support an `enum` field for a basic list of items, and ` multiSelect` field for a similar list of items where the user can select more than one value. + **Note**: The `integer` value is deprecated. + It is still present in the response, + but cannot be used in the POST request. :type type: MetadataTemplateFieldsFieldTypeField :param key: A unique identifier for the field. The identifier must be unique within the template to which it belongs. @@ -4413,8 +4425,11 @@ class FileFullAllowedInviteeRolesField(str, Enum): CO_OWNER = 'co-owner' class FileFullMetadataField(BaseObject): - def __init__(self, **kwargs): + _fields_to_json_mapping: Dict[str, str] = {'extra_data': 'extraData', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'extraData': 'extra_data', **BaseObject._json_to_fields_mapping} + def __init__(self, extra_data: Optional[Dict[str, Dict[str, Metadata]]] = None, **kwargs): super().__init__(**kwargs) + self.extra_data = extra_data class FileFullRepresentationsFieldEntriesFieldContentField(BaseObject): def __init__(self, url_template: Optional[str] = None, **kwargs): @@ -4942,44 +4957,6 @@ def __init__(self, id: Optional[str] = None, type: Optional[ShieldInformationBar self.updated_at = updated_at self.updated_by = updated_by -class ShieldInformationBarrierReportShieldInformationBarrierField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class ShieldInformationBarrierReportStatusField(str, Enum): - PENDING = 'pending' - ERROR = 'error' - DONE = 'done' - CANCELLED = 'cancelled' - -class ShieldInformationBarrierReportDetailsField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class ShieldInformationBarrierReport(ShieldInformationBarrierReportBase): - def __init__(self, shield_information_barrier: Optional[ShieldInformationBarrierReportShieldInformationBarrierField] = None, status: Optional[ShieldInformationBarrierReportStatusField] = None, details: Optional[ShieldInformationBarrierReportDetailsField] = None, created_at: Optional[str] = None, created_by: Optional[UserBase] = None, updated_at: Optional[str] = None, id: Optional[str] = None, type: Optional[ShieldInformationBarrierReportBaseTypeField] = None, **kwargs): - """ - :param status: Status of the shield information report - :type status: Optional[ShieldInformationBarrierReportStatusField], optional - :param created_at: ISO date time string when this - shield information barrier report object was created. - :type created_at: Optional[str], optional - :param updated_at: ISO date time string when this - shield information barrier report was updated. - :type updated_at: Optional[str], optional - :param id: The unique identifier for the shield information barrier report - :type id: Optional[str], optional - :param type: The type of the shield information barrier report - :type type: Optional[ShieldInformationBarrierReportBaseTypeField], optional - """ - super().__init__(id=id, type=type, **kwargs) - self.shield_information_barrier = shield_information_barrier - self.status = status - self.details = details - self.created_at = created_at - self.created_by = created_by - self.updated_at = updated_at - class ShieldInformationBarrierTypeField(str, Enum): SHIELD_INFORMATION_BARRIER = 'shield_information_barrier' @@ -5937,8 +5914,11 @@ def __init__(self, can_delete: bool, can_download: bool, can_invite_collaborator self.can_upload = can_upload class FolderFullMetadataField(BaseObject): - def __init__(self, **kwargs): + _fields_to_json_mapping: Dict[str, str] = {'extra_data': 'extraData', **BaseObject._fields_to_json_mapping} + _json_to_fields_mapping: Dict[str, str] = {'extraData': 'extra_data', **BaseObject._json_to_fields_mapping} + def __init__(self, extra_data: Optional[Dict[str, Dict[str, Metadata]]] = None, **kwargs): super().__init__(**kwargs) + self.extra_data = extra_data class FolderFullAllowedSharedLinkAccessLevelsField(str, Enum): OPEN = 'open' @@ -7113,9 +7093,9 @@ def __init__(self, type: IntegrationMappingPartnerItemSlackTypeField, id: str, s :type type: IntegrationMappingPartnerItemSlackTypeField :param id: ID of the mapped item (of type referenced in `type`) :type id: str - :param slack_workspace_id: ID of the Slack workspace with which the item is associated + :param slack_workspace_id: ID of the Slack workspace with which the item is associated. Use this parameter if Box for Slack is installed at a workspace level. Do not use `slack_org_id` at the same time. :type slack_workspace_id: Optional[str], optional - :param slack_org_id: ID of the Slack organization with which the item is associated + :param slack_org_id: ID of the Slack org with which the item is associated. Use this parameter if Box for Slack is installed at the org level. Do not use `slack_workspace_id` at the same time. :type slack_org_id: Optional[str], optional """ super().__init__(**kwargs) @@ -7127,24 +7107,12 @@ def __init__(self, type: IntegrationMappingPartnerItemSlackTypeField, id: str, s class IntegrationMappingTypeField(str, Enum): INTEGRATION_MAPPING = 'integration_mapping' -class IntegrationMappingBoxItemField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - class IntegrationMappingOptionsField(BaseObject): def __init__(self, **kwargs): super().__init__(**kwargs) -class IntegrationMappingCreatedByField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - -class IntegrationMappingModifiedByField(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) - class IntegrationMapping(IntegrationMappingBase): - def __init__(self, type: IntegrationMappingTypeField, partner_item: Union[IntegrationMappingPartnerItemSlack], box_item: IntegrationMappingBoxItemField, is_manually_created: Optional[bool] = None, options: Optional[IntegrationMappingOptionsField] = None, created_by: Optional[IntegrationMappingCreatedByField] = None, modified_by: Optional[IntegrationMappingModifiedByField] = None, created_at: Optional[str] = None, modified_at: Optional[str] = None, id: Optional[str] = None, integration_type: Optional[IntegrationMappingBaseIntegrationTypeField] = None, **kwargs): + def __init__(self, type: IntegrationMappingTypeField, partner_item: Union[IntegrationMappingPartnerItemSlack], box_item: FolderMini, is_manually_created: Optional[bool] = None, options: Optional[IntegrationMappingOptionsField] = None, created_by: Optional[UserIntegrationMappings] = None, modified_by: Optional[UserIntegrationMappings] = None, created_at: Optional[str] = None, modified_at: Optional[str] = None, id: Optional[str] = None, integration_type: Optional[IntegrationMappingBaseIntegrationTypeField] = None, **kwargs): """ :param type: Mapping type :type type: IntegrationMappingTypeField @@ -7152,7 +7120,7 @@ def __init__(self, type: IntegrationMappingTypeField, partner_item: Union[Integr :type partner_item: Union[IntegrationMappingPartnerItemSlack] :param box_item: The Box folder, to which the object from the partner app domain (referenced in `partner_item_id`) is mapped - :type box_item: IntegrationMappingBoxItemField + :type box_item: FolderMini :param is_manually_created: Identifies whether the mapping has been manually set (as opposed to being automatically created) @@ -7161,10 +7129,10 @@ def __init__(self, type: IntegrationMappingTypeField, partner_item: Union[Integr :type options: Optional[IntegrationMappingOptionsField], optional :param created_by: An object representing the user who created the integration mapping - :type created_by: Optional[IntegrationMappingCreatedByField], optional + :type created_by: Optional[UserIntegrationMappings], optional :param modified_by: The user who last modified the integration mapping - :type modified_by: Optional[IntegrationMappingModifiedByField], optional + :type modified_by: Optional[UserIntegrationMappings], optional :param created_at: When the integration mapping object was created :type created_at: Optional[str], optional :param modified_at: When the integration mapping object was last modified @@ -7225,6 +7193,13 @@ def __init__(self, type: IntegrationMappingBoxItemSlackTypeField, id: str, **kwa self.type = type self.id = id +class IntegrationMappingSlackCreateRequest(BaseObject): + def __init__(self, partner_item: IntegrationMappingPartnerItemSlack, box_item: IntegrationMappingBoxItemSlack, options: Optional[IntegrationMappingSlackOptions] = None, **kwargs): + super().__init__(**kwargs) + self.partner_item = partner_item + self.box_item = box_item + self.options = options + class TimelineSkillCardTypeField(str, Enum): SKILL_CARD = 'skill_card' @@ -8257,6 +8232,36 @@ def __init__(self, details: Optional[ShieldInformationBarrierReportDetailsDetail super().__init__(**kwargs) self.details = details +class ShieldInformationBarrierReportStatusField(str, Enum): + PENDING = 'pending' + ERROR = 'error' + DONE = 'done' + CANCELLED = 'cancelled' + +class ShieldInformationBarrierReport(ShieldInformationBarrierReportBase): + def __init__(self, shield_information_barrier: Optional[ShieldInformationBarrierReference] = None, status: Optional[ShieldInformationBarrierReportStatusField] = None, details: Optional[ShieldInformationBarrierReportDetails] = None, created_at: Optional[str] = None, created_by: Optional[UserBase] = None, updated_at: Optional[str] = None, id: Optional[str] = None, type: Optional[ShieldInformationBarrierReportBaseTypeField] = None, **kwargs): + """ + :param status: Status of the shield information report + :type status: Optional[ShieldInformationBarrierReportStatusField], optional + :param created_at: ISO date time string when this + shield information barrier report object was created. + :type created_at: Optional[str], optional + :param updated_at: ISO date time string when this + shield information barrier report was updated. + :type updated_at: Optional[str], optional + :param id: The unique identifier for the shield information barrier report + :type id: Optional[str], optional + :param type: The type of the shield information barrier report + :type type: Optional[ShieldInformationBarrierReportBaseTypeField], optional + """ + super().__init__(id=id, type=type, **kwargs) + self.shield_information_barrier = shield_information_barrier + self.status = status + self.details = details + self.created_at = created_at + self.created_by = created_by + self.updated_at = updated_at + class TrackingCodeTypeField(str, Enum): TRACKING_CODE = 'tracking_code' @@ -8423,21 +8428,16 @@ def __init__(self, scope: Optional[MetadataFilterScopeField] = None, template_ke self.filters = filters class MetadataFieldFilterString(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) + pass class MetadataFieldFilterFloat(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) + pass class MetadataFieldFilterMultiSelect(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) + pass class MetadataFieldFilterFloatRange(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) + pass class MetadataFieldFilterDateRange(BaseObject): - def __init__(self, **kwargs): - super().__init__(**kwargs) \ No newline at end of file + pass \ No newline at end of file diff --git a/docs/chunked_uploads.md b/docs/chunked_uploads.md index e9d2f89..700b499 100644 --- a/docs/chunked_uploads.md +++ b/docs/chunked_uploads.md @@ -111,6 +111,8 @@ See the endpoint docs at - upload_session_id `str` - The ID of the upload session. Example: "D5E3F7A" +- request_body `ByteStream` + - Request body of uploadFilePart method - digest `str` - The [RFC3230][1] message digest of the chunk uploaded. Only SHA1 is supported. The SHA1 digest must be base64 encoded. The format of this header is as `sha=BASE64_ENCODED_DIGEST`. To get the value for the `SHA` digest, use the openSSL command to encode the file part: `openssl sha1 -binary | base64` [1]: https://tools.ietf.org/html/rfc3230 - content_range `str` diff --git a/docs/classifications.md b/docs/classifications.md index 6036cfa..d5e6575 100644 --- a/docs/classifications.md +++ b/docs/classifications.md @@ -3,6 +3,9 @@ - [List all classifications](#list-all-classifications) - [Delete all classifications](#delete-all-classifications) +- [Add classification](#add-classification) +- [Update classification](#update-classification) +- [Delete classification](#delete-classification) - [Add initial classifications](#add-initial-classifications) ## List all classifications @@ -62,6 +65,105 @@ Returns an empty response when the metadata template for classifications is successfully deleted. +## Add classification + +Adds one or more new classifications to the list of classifications +available to the enterprise. + +This API can also be called by including the enterprise ID in the +URL explicitly, for example +`/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`. + +This operation is performed by calling function `update_metadata_template_enterprise_security_classification_schema_add`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-metadata-templates-enterprise-security-classification-6-vm-vochw-u-wo-schema-add/). + +*Currently we don't have an example for calling `update_metadata_template_enterprise_security_classification_schema_add` in integration tests* + +### Arguments + +- request_body `List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaAddRequestBodyArg]` + - Request body of updateMetadataTemplateEnterpriseSecurityClassificationSchemaAdd method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `ClassificationTemplate`. + +Returns the updated `securityClassification` metadata template, which +contains a `Box__Security__Classification__Key` field that lists all +the classifications available to this enterprise. + + +## Update classification + +Updates the labels and descriptions of one or more classifications +available to the enterprise. + +This API can also be called by including the enterprise ID in the +URL explicitly, for example +`/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`. + +This operation is performed by calling function `update_metadata_template_enterprise_security_classification_schema_update`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-metadata-templates-enterprise-security-classification-6-vm-vochw-u-wo-schema-update/). + +*Currently we don't have an example for calling `update_metadata_template_enterprise_security_classification_schema_update` in integration tests* + +### Arguments + +- request_body `List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdateRequestBodyArg]` + - Request body of updateMetadataTemplateEnterpriseSecurityClassificationSchemaUpdate method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `ClassificationTemplate`. + +Returns the updated `securityClassification` metadata template, which +contains a `Box__Security__Classification__Key` field that lists all +the classifications available to this enterprise. + + +## Delete classification + +Removes a classification from the list of classifications +available to the enterprise. + +This API can also be called by including the enterprise ID in the +URL explicitly, for example +`/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`. + +This operation is performed by calling function `update_metadata_template_enterprise_security_classification_schema_delete`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-metadata-templates-enterprise-security-classification-6-vm-vochw-u-wo-schema-delete/). + +*Currently we don't have an example for calling `update_metadata_template_enterprise_security_classification_schema_delete` in integration tests* + +### Arguments + +- request_body `List[UpdateMetadataTemplateEnterpriseSecurityClassificationSchemaDeleteRequestBodyArg]` + - Request body of updateMetadataTemplateEnterpriseSecurityClassificationSchemaDelete method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `ClassificationTemplate`. + +Returns the updated `securityClassification` metadata template, which +contains a `Box__Security__Classification__Key` field that lists all +the classifications available to this enterprise. + + ## Add initial classifications When an enterprise does not yet have any classifications, this API call @@ -91,7 +193,7 @@ See the endpoint docs at - `false` - copy_instance_on_item_copy `Optional[bool]` - `false` -- fields `Optional[List]` +- fields `Optional[List[CreateMetadataTemplateSchemaClassificationFieldsArg]]` - The classification template holds one field, which holds all the valid classification values. - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. diff --git a/docs/collections.md b/docs/collections.md index 917f916..e2f34f1 100644 --- a/docs/collections.md +++ b/docs/collections.md @@ -16,7 +16,10 @@ This operation is performed by calling function `get_collections`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-collections/). -*Currently we don't have an example for calling `get_collections` in integration tests* + +```python +client.collections.get_collections() +``` ### Arguments @@ -47,7 +50,10 @@ This operation is performed by calling function `get_collection_items`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-collections-id-items/). -*Currently we don't have an example for calling `get_collection_items` in integration tests* + +```python +client.collections.get_collection_items(collection_id=favourite_collection.id) +``` ### Arguments diff --git a/docs/file_classifications.md b/docs/file_classifications.md index de05b2a..0884507 100644 --- a/docs/file_classifications.md +++ b/docs/file_classifications.md @@ -3,6 +3,7 @@ - [Get classification on file](#get-classification-on-file) - [Add classification to file](#add-classification-to-file) +- [Update classification on file](#update-classification-on-file) - [Remove classification from file](#remove-classification-from-file) ## Get classification on file @@ -73,6 +74,38 @@ Returns the classification template instance that was applied to the file. +## Update classification on file + +Updates a classification on a file. + +The classification can only be updated if a classification has already been +applied to the file before. When editing classifications, only values are +defined for the enterprise will be accepted. + +This operation is performed by calling function `update_file_metadata_enterprise_security_classification`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-files-id-metadata-enterprise-security-classification-6-vm-vochw-u-wo/). + +*Currently we don't have an example for calling `update_file_metadata_enterprise_security_classification` in integration tests* + +### Arguments + +- file_id `str` + - The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` is `123`. Example: "12345" +- request_body `List[UpdateFileMetadataEnterpriseSecurityClassificationRequestBodyArg]` + - Request body of updateFileMetadataEnterpriseSecurityClassification method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `Classification`. + +Returns the updated classification metadata template instance. + + ## Remove classification from file Removes any classifications from a file. diff --git a/docs/file_metadata.md b/docs/file_metadata.md index 273015c..3b7b2e5 100644 --- a/docs/file_metadata.md +++ b/docs/file_metadata.md @@ -4,6 +4,7 @@ - [List metadata instances on file](#list-metadata-instances-on-file) - [Get metadata instance on file](#get-metadata-instance-on-file) - [Create metadata instance on file](#create-metadata-instance-on-file) +- [Update metadata instance on file](#update-metadata-instance-on-file) - [Remove metadata instance from file](#remove-metadata-instance-from-file) ## List metadata instances on file @@ -91,6 +92,8 @@ See the endpoint docs at - The scope of the metadata template Example: "global" - template_key `str` - The name of the metadata template Example: "properties" +- request_body `CreateFileMetadataByIdRequestBodyArg` + - Request body of createFileMetadataById method - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. @@ -103,6 +106,46 @@ Returns the instance of the template that was applied to the file, including the data that was applied to the template. +## Update metadata instance on file + +Updates a piece of metadata on a file. + +The metadata instance can only be updated if the template has already been +applied to the file before. When editing metadata, only values that match +the metadata template schema will be accepted. + +The update is applied atomically. If any errors occur during the +application of the operations, the metadata instance will not be changed. + +This operation is performed by calling function `update_file_metadata_by_id`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-files-id-metadata-id-id/). + +*Currently we don't have an example for calling `update_file_metadata_by_id` in integration tests* + +### Arguments + +- file_id `str` + - The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` is `123`. Example: "12345" +- scope `UpdateFileMetadataByIdScopeArg` + - The scope of the metadata template Example: "global" +- template_key `str` + - The name of the metadata template Example: "properties" +- request_body `List[UpdateFileMetadataByIdRequestBodyArg]` + - Request body of updateFileMetadataById method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `Metadata`. + +Returns the updated metadata template instance, with the +custom template data included. + + ## Remove metadata instance from file Deletes a piece of file metadata. diff --git a/docs/folder_classifications.md b/docs/folder_classifications.md index 2ea1c19..0937542 100644 --- a/docs/folder_classifications.md +++ b/docs/folder_classifications.md @@ -3,6 +3,7 @@ - [Get classification on folder](#get-classification-on-folder) - [Add classification to folder](#add-classification-to-folder) +- [Update classification on folder](#update-classification-on-folder) - [Remove classification from folder](#remove-classification-from-folder) ## Get classification on folder @@ -73,6 +74,38 @@ Returns the classification template instance that was applied to the folder. +## Update classification on folder + +Updates a classification on a folder. + +The classification can only be updated if a classification has already been +applied to the folder before. When editing classifications, only values are +defined for the enterprise will be accepted. + +This operation is performed by calling function `update_folder_metadata_enterprise_security_classification`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-folders-id-metadata-enterprise-security-classification-6-vm-vochw-u-wo/). + +*Currently we don't have an example for calling `update_folder_metadata_enterprise_security_classification` in integration tests* + +### Arguments + +- folder_id `str` + - The unique identifier that represent a folder. The ID for any folder can be determined by visiting this folder in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/folder/123` the `folder_id` is `123`. The root folder of a Box account is always represented by the ID `0`. Example: "12345" +- request_body `List[UpdateFolderMetadataEnterpriseSecurityClassificationRequestBodyArg]` + - Request body of updateFolderMetadataEnterpriseSecurityClassification method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `Classification`. + +Returns the updated classification metadata template instance. + + ## Remove classification from folder Removes any classifications from a folder. diff --git a/docs/folder_locks.md b/docs/folder_locks.md index b939446..754ccf9 100644 --- a/docs/folder_locks.md +++ b/docs/folder_locks.md @@ -17,7 +17,10 @@ This operation is performed by calling function `get_folder_locks`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-folder-locks/). -*Currently we don't have an example for calling `get_folder_locks` in integration tests* + +```python +client.folder_locks.get_folder_locks(folder_id=folder.id) +``` ### Arguments @@ -48,7 +51,10 @@ This operation is performed by calling function `create_folder_lock`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-folder-locks/). -*Currently we don't have an example for calling `create_folder_lock` in integration tests* + +```python +client.folder_locks.create_folder_lock(locked_operations=CreateFolderLockLockedOperationsArg(move=True, delete=True), folder=CreateFolderLockFolderArg(id=folder.id, type='folder')) +``` ### Arguments @@ -80,7 +86,10 @@ This operation is performed by calling function `delete_folder_lock_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-folder-locks-id/). -*Currently we don't have an example for calling `delete_folder_lock_by_id` in integration tests* + +```python +client.folder_locks.delete_folder_lock_by_id(folder_lock_id=folder_lock.id) +``` ### Arguments diff --git a/docs/folder_metadata.md b/docs/folder_metadata.md index e663813..198933c 100644 --- a/docs/folder_metadata.md +++ b/docs/folder_metadata.md @@ -4,6 +4,7 @@ - [List metadata instances on folder](#list-metadata-instances-on-folder) - [Get metadata instance on folder](#get-metadata-instance-on-folder) - [Create metadata instance on folder](#create-metadata-instance-on-folder) +- [Update metadata instance on folder](#update-metadata-instance-on-folder) - [Remove metadata instance from folder](#remove-metadata-instance-from-folder) ## List metadata instances on folder @@ -96,6 +97,8 @@ See the endpoint docs at - The scope of the metadata template Example: "global" - template_key `str` - The name of the metadata template Example: "properties" +- request_body `CreateFolderMetadataByIdRequestBodyArg` + - Request body of createFolderMetadataById method - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. @@ -108,6 +111,46 @@ Returns the instance of the template that was applied to the folder, including the data that was applied to the template. +## Update metadata instance on folder + +Updates a piece of metadata on a folder. + +The metadata instance can only be updated if the template has already been +applied to the folder before. When editing metadata, only values that match +the metadata template schema will be accepted. + +The update is applied atomically. If any errors occur during the +application of the operations, the metadata instance will not be changed. + +This operation is performed by calling function `update_folder_metadata_by_id`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-folders-id-metadata-id-id/). + +*Currently we don't have an example for calling `update_folder_metadata_by_id` in integration tests* + +### Arguments + +- folder_id `str` + - The unique identifier that represent a folder. The ID for any folder can be determined by visiting this folder in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/folder/123` the `folder_id` is `123`. The root folder of a Box account is always represented by the ID `0`. Example: "12345" +- scope `UpdateFolderMetadataByIdScopeArg` + - The scope of the metadata template Example: "global" +- template_key `str` + - The name of the metadata template Example: "properties" +- request_body `List[UpdateFolderMetadataByIdRequestBodyArg]` + - Request body of updateFolderMetadataById method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `Metadata`. + +Returns the updated metadata template instance, with the +custom template data included. + + ## Remove metadata instance from folder Deletes a piece of folder metadata. diff --git a/docs/integration_mappings.md b/docs/integration_mappings.md index e5e844e..768add9 100644 --- a/docs/integration_mappings.md +++ b/docs/integration_mappings.md @@ -64,11 +64,11 @@ See the endpoint docs at ### Arguments -- partner_item `CreateIntegrationMappingSlackPartnerItemArg` +- partner_item `IntegrationMappingPartnerItemSlack` - -- box_item `CreateIntegrationMappingSlackBoxItemArg` +- box_item `IntegrationMappingBoxItemSlack` - -- options `Optional[CreateIntegrationMappingSlackOptionsArg]` +- options `Optional[IntegrationMappingSlackOptions]` - - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. @@ -100,9 +100,9 @@ See the endpoint docs at - integration_mapping_id `str` - An ID of an integration mapping Example: "11235432" -- box_item `Optional[UpdateIntegrationMappingSlackByIdBoxItemArg]` +- box_item `Optional[IntegrationMappingBoxItemSlack]` - -- options `Optional[UpdateIntegrationMappingSlackByIdOptionsArg]` +- options `Optional[IntegrationMappingSlackOptions]` - - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. diff --git a/docs/memberships.md b/docs/memberships.md index a50a075..bce7790 100644 --- a/docs/memberships.md +++ b/docs/memberships.md @@ -103,7 +103,7 @@ client.memberships.create_group_membership(user=user, group=group) - The group to add the user to. - role `Optional[CreateGroupMembershipRoleArg]` - The role of the user in the group. -- configurable_permissions `Optional[CreateGroupMembershipConfigurablePermissionsArg]` +- configurable_permissions `Optional[Dict[str, bool]]` - Custom configuration for the permissions an admin if a group will receive. This option has no effect on members with a role of `member`. Setting these permissions overwrites the default access levels of an admin. Specifying a value of "null" for this object will disable all configurable permissions. Specifying permissions will set them accordingly, omitted permissions will be enabled by default. - fields `Optional[str]` - A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response. Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested. @@ -173,7 +173,7 @@ client.memberships.update_group_membership_by_id(group_membership_id=group_membe - The ID of the group membership. Example: "434534" - role `Optional[UpdateGroupMembershipByIdRoleArg]` - The role of the user in the group. -- configurable_permissions `Optional[UpdateGroupMembershipByIdConfigurablePermissionsArg]` +- configurable_permissions `Optional[Dict[str, bool]]` - Custom configuration for the permissions an admin if a group will receive. This option has no effect on members with a role of `member`. Setting these permissions overwrites the default access levels of an admin. Specifying a value of "null" for this object will disable all configurable permissions. Specifying permissions will set them accordingly, omitted permissions will be enabled by default. - fields `Optional[str]` - A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response. Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested. diff --git a/docs/metadata_templates.md b/docs/metadata_templates.md index ad72e84..d369190 100644 --- a/docs/metadata_templates.md +++ b/docs/metadata_templates.md @@ -3,6 +3,7 @@ - [Find metadata template by instance ID](#find-metadata-template-by-instance-id) - [Get metadata template by name](#get-metadata-template-by-name) +- [Update metadata template](#update-metadata-template) - [Remove metadata template](#remove-metadata-template) - [Get metadata template by ID](#get-metadata-template-by-id) - [List all global metadata templates](#list-all-global-metadata-templates) @@ -69,6 +70,43 @@ Returns the metadata template matching the `scope` and `template` name. +## Update metadata template + +Updates a metadata template. + +The metadata template can only be updated if the template +already exists. + +The update is applied atomically. If any errors occur during the +application of the operations, the metadata template will not be changed. + +This operation is performed by calling function `update_metadata_template_schema`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-metadata-templates-id-id-schema/). + +*Currently we don't have an example for calling `update_metadata_template_schema` in integration tests* + +### Arguments + +- scope `UpdateMetadataTemplateSchemaScopeArg` + - The scope of the metadata template Example: "global" +- template_key `str` + - The name of the metadata template Example: "properties" +- request_body `List[UpdateMetadataTemplateSchemaRequestBodyArg]` + - Request body of updateMetadataTemplateSchema method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `MetadataTemplate`. + +Returns the updated metadata template, with the +custom template data included. + + ## Remove metadata template Delete a metadata template and its instances. @@ -207,7 +245,7 @@ See the endpoint docs at - The display name of the template. - hidden `Optional[bool]` - Defines if this template is visible in the Box web app UI, or if it is purely intended for usage through the API. -- fields `Optional[List]` +- fields `Optional[List[CreateMetadataTemplateSchemaFieldsArg]]` - An ordered list of template fields which are part of the template. Each field can be a regular text field, date field, number field, as well as a single or multi-select list. - copy_instance_on_item_copy `Optional[bool]` - Whether or not to copy any metadata attached to a file or folder when it is copied. By default, metadata is not copied along with a file or folder when it is copied. diff --git a/docs/recent_items.md b/docs/recent_items.md index 8861acb..9380731 100644 --- a/docs/recent_items.md +++ b/docs/recent_items.md @@ -14,7 +14,10 @@ This operation is performed by calling function `get_recent_items`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-recent-items/). -*Currently we don't have an example for calling `get_recent_items` in integration tests* + +```python +client.recent_items.get_recent_items() +``` ### Arguments diff --git a/docs/retention_policy_assignments.md b/docs/retention_policy_assignments.md index e8102b4..b69d8c2 100644 --- a/docs/retention_policy_assignments.md +++ b/docs/retention_policy_assignments.md @@ -61,7 +61,7 @@ See the endpoint docs at - The ID of the retention policy to assign - assign_to `CreateRetentionPolicyAssignmentAssignToArg` - The item to assign the policy to -- filter_fields `Optional[List]` +- filter_fields `Optional[List[CreateRetentionPolicyAssignmentFilterFieldsArg]]` - If the `assign_to` type is `metadata_template`, then optionally add the `filter_fields` parameter which will require an array of objects with a field entry and a value entry. Currently only one object of `field` and `value` is supported. - start_date_field `Optional[str]` - The date the retention policy assignment begins. If the `assigned_to` type is `metadata_template`, this field can be a date field's metadata attribute key id. diff --git a/docs/search.md b/docs/search.md index 84cde5f..3adaedb 100644 --- a/docs/search.md +++ b/docs/search.md @@ -27,11 +27,11 @@ See the endpoint docs at - Specifies the template used in the query. Must be in the form `scope.templateKey`. Not all templates can be used in this field, most notably the built-in, Box-provided classification templates can not be used in a query. - query `Optional[str]` - The query to perform. A query is a logical expression that is very similar to a SQL `SELECT` statement. Values in the search query can be turned into parameters specified in the `query_param` arguments list to prevent having to manually insert search values into the query string. For example, a value of `:amount` would represent the `amount` value in `query_params` object. -- query_params `Optional[CreateMetadataQueryExecuteReadQueryParamsArg]` +- query_params `Optional[Dict[str, str]]` - Set of arguments corresponding to the parameters specified in the `query`. The type of each parameter used in the `query_params` must match the type of the corresponding metadata template field. - ancestor_folder_id `str` - The ID of the folder that you are restricting the query to. A value of zero will return results from all folders you have access to. A non-zero value will only return results found in the folder corresponding to the ID or in any of its subfolders. -- order_by `Optional[List]` +- order_by `Optional[List[CreateMetadataQueryExecuteReadOrderByArg]]` - A list of template fields and directions to sort the metadata query results by. The ordering `direction` must be the same for each item in the array. - limit `Optional[int]` - A value between 0 and 100 that indicates the maximum number of results to return for a single request. This only specifies a maximum boundary and will not guarantee the minimum number of results returned. diff --git a/docs/skills.md b/docs/skills.md index d88de27..c090b10 100644 --- a/docs/skills.md +++ b/docs/skills.md @@ -3,6 +3,7 @@ - [List Box Skill cards on file](#list-box-skill-cards-on-file) - [Create Box Skill cards on file](#create-box-skill-cards-on-file) +- [Update Box Skill cards on file](#update-box-skill-cards-on-file) - [Remove Box Skill cards from file](#remove-box-skill-cards-from-file) - [Update all Box Skill cards on file](#update-all-box-skill-cards-on-file) @@ -64,6 +65,35 @@ Returns the instance of the template that was applied to the file, including the data that was applied to the template. +## Update Box Skill cards on file + +Updates one or more Box Skills metadata cards to a file. + +This operation is performed by calling function `update_file_metadata_global_box_skills_card`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/put-files-id-metadata-global-box-skills-cards/). + +*Currently we don't have an example for calling `update_file_metadata_global_box_skills_card` in integration tests* + +### Arguments + +- file_id `str` + - The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` is `123`. Example: "12345" +- request_body `List[UpdateFileMetadataGlobalBoxSkillsCardRequestBodyArg]` + - Request body of updateFileMetadataGlobalBoxSkillsCard method +- extra_headers `Optional[Dict[str, Optional[str]]]` + - Extra headers that will be included in the HTTP request. + + +### Returns + +This function returns a value of type `SkillCardsMetadata`. + +Returns the updated metadata template, with the +custom template data included. + + ## Remove Box Skill cards from file Removes any Box Skills cards metadata from a file. diff --git a/docs/trashed_files.md b/docs/trashed_files.md index 6e793b4..2da0e83 100644 --- a/docs/trashed_files.md +++ b/docs/trashed_files.md @@ -17,7 +17,10 @@ This operation is performed by calling function `restore_file_from_trash`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-files-id/). -*Currently we don't have an example for calling `restore_file_from_trash` in integration tests* + +```python +client.trashed_files.restore_file_from_trash(file_id=file.id) +``` ### Arguments @@ -61,7 +64,7 @@ See the endpoint docs at ```python -client.trashed_files.get_file_trash(file_id=uploaded_file.id) +client.trashed_files.get_file_trash(file_id=file.id) ``` ### Arguments @@ -93,7 +96,10 @@ This operation is performed by calling function `delete_file_trash`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-files-id-trash/). -*Currently we don't have an example for calling `delete_file_trash` in integration tests* + +```python +client.trashed_files.delete_file_trash(file_id=file.id) +``` ### Arguments diff --git a/docs/trashed_folders.md b/docs/trashed_folders.md index 2c4607a..2c1383b 100644 --- a/docs/trashed_folders.md +++ b/docs/trashed_folders.md @@ -26,7 +26,10 @@ This operation is performed by calling function `restore_folder_from_trash`. See the endpoint docs at [API Reference](https://developer.box.com/reference/post-folders-id/). -*Currently we don't have an example for calling `restore_folder_from_trash` in integration tests* + +```python +client.trashed_folders.restore_folder_from_trash(folder_id=folder.id) +``` ### Arguments @@ -68,7 +71,10 @@ This operation is performed by calling function `get_folder_trash`. See the endpoint docs at [API Reference](https://developer.box.com/reference/get-folders-id-trash/). -*Currently we don't have an example for calling `get_folder_trash` in integration tests* + +```python +client.trashed_folders.get_folder_trash(folder_id=folder.id) +``` ### Arguments @@ -99,7 +105,10 @@ This operation is performed by calling function `delete_folder_trash`. See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-folders-id-trash/). -*Currently we don't have an example for calling `delete_folder_trash` in integration tests* + +```python +client.trashed_folders.delete_folder_trash(folder_id=folder.id) +``` ### Arguments diff --git a/docs/webhooks.md b/docs/webhooks.md index 3824654..4728d3c 100644 --- a/docs/webhooks.md +++ b/docs/webhooks.md @@ -54,7 +54,7 @@ See the endpoint docs at ```python -client.webhooks.create_webhook(target=CreateWebhookTargetArg(id=folder.id, type=CreateWebhookTargetArgTypeField.FOLDER.value), address='https://example.com/new-webhook', triggers=['FILE.UPLOADED']) +client.webhooks.create_webhook(target=CreateWebhookTargetArg(id=folder.id, type=CreateWebhookTargetArgTypeField.FOLDER.value), address='https://example.com/new-webhook', triggers=[CreateWebhookTriggersArg.FILE_UPLOADED.value]) ``` ### Arguments @@ -63,7 +63,7 @@ client.webhooks.create_webhook(target=CreateWebhookTargetArg(id=folder.id, type= - The item that will trigger the webhook - address `str` - The URL that is notified by this webhook -- triggers `List[Union[str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str]]` +- triggers `List[CreateWebhookTriggersArg]` - An array of event names that this webhook is to be triggered for - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. @@ -127,7 +127,7 @@ client.webhooks.update_webhook_by_id(webhook_id=webhook.id, address='https://exa - The item that will trigger the webhook - address `Optional[str]` - The URL that is notified by this webhook -- triggers `Optional[List[Union[str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str]]]` +- triggers `Optional[List[UpdateWebhookByIdTriggersArg]]` - An array of event names that this webhook is to be triggered for - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. diff --git a/docs/workflows.md b/docs/workflows.md index c070215..a84f3f7 100644 --- a/docs/workflows.md +++ b/docs/workflows.md @@ -62,11 +62,11 @@ See the endpoint docs at - The type of the parameters object - flow `CreateWorkflowStartFlowArg` - The flow that will be triggered -- files `List` +- files `List[CreateWorkflowStartFilesArg]` - The array of files for which the workflow should start. All files must be in the workflow's configured folder. - folder `CreateWorkflowStartFolderArg` - The folder object for which the workflow is configured. -- outcomes `Optional[List]` +- outcomes `Optional[List[CreateWorkflowStartOutcomesArg]]` - A list of outcomes required to be configured at start time. - extra_headers `Optional[Dict[str, Optional[str]]]` - Extra headers that will be included in the HTTP request. diff --git a/docs/zip_downloads.md b/docs/zip_downloads.md index 8390171..9f96afe 100644 --- a/docs/zip_downloads.md +++ b/docs/zip_downloads.md @@ -33,7 +33,7 @@ See the endpoint docs at ### Arguments -- items `List` +- items `List[CreateZipDownloadItemsArg]` - A list of items to add to the `zip` archive. These can be folders or files. - download_file_name `Optional[str]` - The optional name of the `zip` archive. This name will be appended by the `.zip` file extension, for example `January Financials.zip`. diff --git a/test/collections.py b/test/collections.py new file mode 100644 index 0000000..15ece86 --- /dev/null +++ b/test/collections.py @@ -0,0 +1,34 @@ +from box_sdk_gen.managers.folders import CreateFolderParentArg + +from box_sdk_gen.managers.folders import UpdateFolderByIdCollectionsArg + +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import Client + +from box_sdk_gen.jwt_auth import JWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + +jwt_config = JWTConfig.from_config_json_string(decode_base_64(get_env_var('JWT_CONFIG_BASE_64'))) + +auth: JWTAuth = JWTAuth(config=jwt_config) + +client: Client = Client(auth=auth) + +def testCollections(): + collections: Collections = client.collections.get_collections() + favourite_collection: Collections = collections.entries[0] + collection_items: Items = client.collections.get_collection_items(collection_id=favourite_collection.id) + folder: FolderFull = client.folders.create_folder(name=get_uuid(), parent=CreateFolderParentArg(id='0')) + client.folders.update_folder_by_id(folder_id=folder.id, collections=[UpdateFolderByIdCollectionsArg(id=favourite_collection.id)]) + collection_items_after_update: Items = client.collections.get_collection_items(collection_id=favourite_collection.id) + assert len(collection_items_after_update.entries) == len(collection_items.entries) + 1 + client.folders.update_folder_by_id(folder_id=folder.id, collections=[]) + collection_items_after_remove: Items = client.collections.get_collection_items(collection_id=favourite_collection.id) + assert len(collection_items_after_remove.entries) == len(collection_items.entries) + client.folders.delete_folder_by_id(folder_id=folder.id) \ No newline at end of file diff --git a/test/folder_locks.py b/test/folder_locks.py new file mode 100644 index 0000000..95f2f52 --- /dev/null +++ b/test/folder_locks.py @@ -0,0 +1,42 @@ +import pytest + +from box_sdk_gen.managers.folders import CreateFolderParentArg + +from box_sdk_gen.managers.folder_locks import CreateFolderLockLockedOperationsArg + +from box_sdk_gen.managers.folder_locks import CreateFolderLockFolderArg + +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import Client + +from box_sdk_gen.jwt_auth import JWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + +jwt_config = JWTConfig.from_config_json_string(decode_base_64(get_env_var('JWT_CONFIG_BASE_64'))) + +auth: JWTAuth = JWTAuth(config=jwt_config) + +client: Client = Client(auth=auth) + +def testFolderLocks(): + folder: FolderFull = client.folders.create_folder(name=get_uuid(), parent=CreateFolderParentArg(id='0')) + folder_locks: FolderLocks = client.folder_locks.get_folder_locks(folder_id=folder.id) + assert len(folder_locks.entries) == 0 + folder_lock: FolderLock = client.folder_locks.create_folder_lock(locked_operations=CreateFolderLockLockedOperationsArg(move=True, delete=True), folder=CreateFolderLockFolderArg(id=folder.id, type='folder')) + assert folder_lock.folder.id == folder.id + assert folder_lock.locked_operations.move == True + assert folder_lock.locked_operations.delete == True + with pytest.raises(Exception): + client.folders.delete_folder_by_id(folder_id=folder.id) + client.folder_locks.delete_folder_lock_by_id(folder_lock_id=folder_lock.id) + with pytest.raises(Exception): + client.folder_locks.delete_folder_lock_by_id(folder_lock_id=folder_lock.id) + new_folder_locks: FolderLocks = client.folder_locks.get_folder_locks(folder_id=folder.id) + assert len(new_folder_locks.entries) == 0 + client.folders.delete_folder_by_id(folder_id=folder.id) \ No newline at end of file diff --git a/test/recent_items.py b/test/recent_items.py new file mode 100644 index 0000000..e516444 --- /dev/null +++ b/test/recent_items.py @@ -0,0 +1,21 @@ +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import Client + +from box_sdk_gen.jwt_auth import JWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + +jwt_config = JWTConfig.from_config_json_string(decode_base_64(get_env_var('JWT_CONFIG_BASE_64'))) + +auth: JWTAuth = JWTAuth(config=jwt_config) + +def testRecentItems(): + auth.as_user(get_env_var('USER_ID')) + client: Client = Client(auth=auth) + recent_items: RecentItems = client.recent_items.get_recent_items() + assert len(recent_items.entries) > 0 \ No newline at end of file diff --git a/test/trashed_files.py b/test/trashed_files.py new file mode 100644 index 0000000..c4a9890 --- /dev/null +++ b/test/trashed_files.py @@ -0,0 +1,47 @@ +import pytest + +from box_sdk_gen.managers.uploads import UploadFileAttributesArg + +from box_sdk_gen.managers.uploads import UploadFileAttributesArgParentField + +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.utils import generate_byte_stream + +from box_sdk_gen.client import Client + +from box_sdk_gen.jwt_auth import JWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + +jwt_config = JWTConfig.from_config_json_string(decode_base_64(get_env_var('JWT_CONFIG_BASE_64'))) + +auth: JWTAuth = JWTAuth(config=jwt_config) + +client: Client = Client(auth=auth) + +def testTrashedFiles(): + file_size = 1024 * 1024 + file_name: str = get_uuid() + file_byte_stream: ByteStream = generate_byte_stream(file_size) + files: Files = client.uploads.upload_file(attributes=UploadFileAttributesArg(name=file_name, parent=UploadFileAttributesArgParentField(id='0')), file=file_byte_stream) + file: Files = files.entries[0] + client.files.delete_file_by_id(file_id=file.id) + from_trash: TrashFile = client.trashed_files.get_file_trash(file_id=file.id) + assert from_trash.id == file.id + assert from_trash.name == file.name + from_api_after_trashed: FileFull = client.files.get_file_by_id(file_id=file.id) + assert from_api_after_trashed.item_status == 'trashed' + restored_file: TrashFileRestored = client.trashed_files.restore_file_from_trash(file_id=file.id) + from_api_after_restore: FileFull = client.files.get_file_by_id(file_id=file.id) + assert restored_file.id == from_api_after_restore.id + assert restored_file.name == from_api_after_restore.name + assert from_api_after_restore.item_status == 'active' + client.files.delete_file_by_id(file_id=file.id) + client.trashed_files.delete_file_trash(file_id=file.id) + with pytest.raises(Exception): + client.trashed_files.get_file_trash(file_id=file.id) \ No newline at end of file diff --git a/test/trashed_folders.py b/test/trashed_folders.py new file mode 100644 index 0000000..3d77720 --- /dev/null +++ b/test/trashed_folders.py @@ -0,0 +1,38 @@ +import pytest + +from box_sdk_gen.managers.folders import CreateFolderParentArg + +from box_sdk_gen.utils import decode_base_64 + +from box_sdk_gen.utils import get_env_var + +from box_sdk_gen.utils import get_uuid + +from box_sdk_gen.client import Client + +from box_sdk_gen.jwt_auth import JWTAuth + +from box_sdk_gen.jwt_auth import JWTConfig + +jwt_config = JWTConfig.from_config_json_string(decode_base_64(get_env_var('JWT_CONFIG_BASE_64'))) + +auth: JWTAuth = JWTAuth(config=jwt_config) + +client: Client = Client(auth=auth) + +def testTrashedFolders(): + folder: FolderFull = client.folders.create_folder(name=get_uuid(), parent=CreateFolderParentArg(id='0')) + client.folders.delete_folder_by_id(folder_id=folder.id) + from_trash: TrashFolder = client.trashed_folders.get_folder_trash(folder_id=folder.id) + assert from_trash.id == folder.id + assert from_trash.name == folder.name + with pytest.raises(Exception): + client.folders.get_folder_by_id(folder_id=folder.id) + restored_folder: TrashFolderRestored = client.trashed_folders.restore_folder_from_trash(folder_id=folder.id) + from_api: FolderFull = client.folders.get_folder_by_id(folder_id=folder.id) + assert restored_folder.id == from_api.id + assert restored_folder.name == from_api.name + client.folders.delete_folder_by_id(folder_id=folder.id) + client.trashed_folders.delete_folder_trash(folder_id=folder.id) + with pytest.raises(Exception): + client.trashed_folders.get_folder_trash(folder_id=folder.id) \ No newline at end of file diff --git a/test/webhooks.py b/test/webhooks.py index dd7ef9c..4e6f783 100644 --- a/test/webhooks.py +++ b/test/webhooks.py @@ -6,6 +6,8 @@ from box_sdk_gen.managers.webhooks import CreateWebhookTargetArgTypeField +from box_sdk_gen.managers.webhooks import CreateWebhookTriggersArg + from box_sdk_gen.utils import decode_base_64 from box_sdk_gen.utils import get_env_var @@ -26,7 +28,7 @@ def testWebhooksCRUD(): folder: FolderFull = client.folders.create_folder(name=get_uuid(), parent=CreateFolderParentArg(id='0')) - webhook: Webhook = client.webhooks.create_webhook(target=CreateWebhookTargetArg(id=folder.id, type=CreateWebhookTargetArgTypeField.FOLDER.value), address='https://example.com/new-webhook', triggers=['FILE.UPLOADED']) + webhook: Webhook = client.webhooks.create_webhook(target=CreateWebhookTargetArg(id=folder.id, type=CreateWebhookTargetArgTypeField.FOLDER.value), address='https://example.com/new-webhook', triggers=[CreateWebhookTriggersArg.FILE_UPLOADED.value]) assert webhook.target.id == folder.id assert webhook.target.type == 'folder' assert len(webhook.triggers) == len(['FILE.UPLOADED'])