From f91076e1bfbccae4a0dff4b66d7bafb5357858c5 Mon Sep 17 00:00:00 2001 From: box-sdk-build <94016436+box-sdk-build@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:00:32 +0200 Subject: [PATCH] feat: Support sending fields with `null` value (box/box-codegen#528) (#230) Fixes: #202 --- .codegen.json | 2 +- box_sdk_gen/internal/__init__.py | 2 + box_sdk_gen/internal/base_object.py | 5 +- box_sdk_gen/internal/null_value.py | 5 ++ box_sdk_gen/internal/utils.py | 5 ++ box_sdk_gen/managers/file_versions.py | 8 ++- box_sdk_gen/managers/files.py | 14 ++-- box_sdk_gen/managers/folders.py | 14 +++- box_sdk_gen/managers/memberships.py | 12 ++-- box_sdk_gen/managers/retention_policies.py | 34 ++++++---- box_sdk_gen/managers/shared_links_files.py | 10 ++- box_sdk_gen/managers/shared_links_folders.py | 10 ++- .../managers/shared_links_web_links.py | 10 ++- .../shield_information_barrier_segments.py | 8 ++- box_sdk_gen/managers/sign_requests.py | 50 +++++++------- box_sdk_gen/managers/users.py | 14 ++-- docs/file_versions.md | 18 +++-- docs/users.md | 2 +- test/file_versions.py | 66 ++++++++++++++++--- test/files.py | 21 ++++++ test/users.py | 21 ++++++ 21 files changed, 252 insertions(+), 79 deletions(-) create mode 100644 box_sdk_gen/internal/null_value.py diff --git a/.codegen.json b/.codegen.json index 320a6fc5..ea386d98 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "f6b5758", "specHash": "d36b9f0", "version": "1.1.0" } +{ "engineHash": "5972afb", "specHash": "d36b9f0", "version": "1.1.0" } diff --git a/box_sdk_gen/internal/__init__.py b/box_sdk_gen/internal/__init__.py index b0a4d467..f36dae96 100644 --- a/box_sdk_gen/internal/__init__.py +++ b/box_sdk_gen/internal/__init__.py @@ -1,3 +1,5 @@ from box_sdk_gen.internal.base_object import * +from box_sdk_gen.internal.null_value import * + from box_sdk_gen.internal.utils import * diff --git a/box_sdk_gen/internal/base_object.py b/box_sdk_gen/internal/base_object.py index 48760b9e..be247e74 100644 --- a/box_sdk_gen/internal/base_object.py +++ b/box_sdk_gen/internal/base_object.py @@ -1,6 +1,7 @@ from datetime import datetime, date from enum import EnumMeta, Enum from typing import get_args, get_origin, Union, Optional +from .null_value import NullValue class BaseObject: @@ -27,7 +28,9 @@ def to_dict(self) -> dict: for k, v in vars(self).items(): if v is None: continue - if type(v) is list: + if isinstance(v, NullValue): + value = None + elif type(v) is list: value = [ item.to_dict() if isinstance(item, BaseObject) else item for item in v diff --git a/box_sdk_gen/internal/null_value.py b/box_sdk_gen/internal/null_value.py new file mode 100644 index 00000000..9001c9a0 --- /dev/null +++ b/box_sdk_gen/internal/null_value.py @@ -0,0 +1,5 @@ +class NullValue: + pass + + +null = NullValue() diff --git a/box_sdk_gen/internal/utils.py b/box_sdk_gen/internal/utils.py index 85ac81d6..1e4a5d72 100644 --- a/box_sdk_gen/internal/utils.py +++ b/box_sdk_gen/internal/utils.py @@ -18,6 +18,7 @@ from .base_object import BaseObject from ..serialization.json.json_data import sd_to_json from ..serialization.json.serializer import serialize +from .null_value import null ByteStream = BufferedIOBase Buffer = bytes @@ -304,3 +305,7 @@ def date_time_to_string(date_time: DateTime) -> str: def date_time_from_string(date_time: str) -> DateTime: return DateTime.fromisoformat(date_time.replace('Z', '+00:00')) + + +def create_null(): + return null diff --git a/box_sdk_gen/managers/file_versions.py b/box_sdk_gen/managers/file_versions.py index eb3861be..8b6a9189 100644 --- a/box_sdk_gen/managers/file_versions.py +++ b/box_sdk_gen/managers/file_versions.py @@ -10,6 +10,10 @@ from box_sdk_gen.serialization.json.serializer import deserialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.serialization.json.serializer import serialize from box_sdk_gen.schemas.file_versions import FileVersions @@ -200,7 +204,7 @@ def update_file_version_by_id( file_id: str, file_version_id: str, *, - trashed_at: Optional[str] = None, + trashed_at: Union[Optional[str], NullValue] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> FileVersionFull: """ @@ -228,7 +232,7 @@ def update_file_version_by_id( :type file_version_id: str :param trashed_at: Set this to `null` to clear the date and restore the file., defaults to None - :type trashed_at: Optional[str], optional + :type trashed_at: Union[Optional[str], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/files.py b/box_sdk_gen/managers/files.py index b79c2d97..d80ee394 100644 --- a/box_sdk_gen/managers/files.py +++ b/box_sdk_gen/managers/files.py @@ -12,6 +12,10 @@ from box_sdk_gen.serialization.json.serializer import deserialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.serialization.json.serializer import serialize from box_sdk_gen.schemas.file_full import FileFull @@ -330,11 +334,11 @@ def update_file_by_id( name: Optional[str] = None, description: Optional[str] = None, parent: Optional[UpdateFileByIdParent] = None, - shared_link: Optional[UpdateFileByIdSharedLink] = None, - lock: Optional[UpdateFileByIdLock] = None, + shared_link: Union[Optional[UpdateFileByIdSharedLink], NullValue] = None, + lock: Union[Optional[UpdateFileByIdLock], NullValue] = None, disposition_at: Optional[DateTime] = None, permissions: Optional[UpdateFileByIdPermissions] = None, - collections: Optional[List[UpdateFileByIdCollections]] = None, + collections: Union[Optional[List[UpdateFileByIdCollections]], NullValue] = None, tags: Optional[List[str]] = None, fields: Optional[List[str]] = None, if_match: Optional[str] = None, @@ -367,7 +371,7 @@ def update_file_by_id( who created the lock. Set this to `null` to remove the lock., defaults to None - :type lock: Optional[UpdateFileByIdLock], optional + :type lock: Union[Optional[UpdateFileByIdLock], NullValue], optional :param disposition_at: The retention expiration timestamp for the given file. This date cannot be shortened once set on a file., defaults to None :type disposition_at: Optional[DateTime], optional @@ -384,7 +388,7 @@ def update_file_by_id( the file from all collections. [1]: e://get-collections, defaults to None - :type collections: Optional[List[UpdateFileByIdCollections]], optional + :type collections: Union[Optional[List[UpdateFileByIdCollections]], NullValue], optional :param tags: The tags for this item. These tags are shown in the Box web app and mobile apps next to an item. diff --git a/box_sdk_gen/managers/folders.py b/box_sdk_gen/managers/folders.py index a92256e5..5dd024a8 100644 --- a/box_sdk_gen/managers/folders.py +++ b/box_sdk_gen/managers/folders.py @@ -12,6 +12,10 @@ from box_sdk_gen.serialization.json.serializer import deserialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.serialization.json.serializer import serialize from box_sdk_gen.schemas.folder_full import FolderFull @@ -440,10 +444,14 @@ def update_folder_by_id( can_non_owners_invite: Optional[bool] = None, parent: Optional[UpdateFolderByIdParent] = None, shared_link: Optional[UpdateFolderByIdSharedLink] = None, - folder_upload_email: Optional[UpdateFolderByIdFolderUploadEmail] = None, + folder_upload_email: Union[ + Optional[UpdateFolderByIdFolderUploadEmail], NullValue + ] = None, tags: Optional[List[str]] = None, is_collaboration_restricted_to_enterprise: Optional[bool] = None, - collections: Optional[List[UpdateFolderByIdCollections]] = None, + collections: Union[ + Optional[List[UpdateFolderByIdCollections]], NullValue + ] = None, can_non_owners_view_collaborators: Optional[bool] = None, fields: Optional[List[str]] = None, if_match: Optional[str] = None, @@ -504,7 +512,7 @@ def update_folder_by_id( the folder from all collections. [1]: e://get-collections, defaults to None - :type collections: Optional[List[UpdateFolderByIdCollections]], optional + :type collections: Union[Optional[List[UpdateFolderByIdCollections]], NullValue], 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/memberships.py b/box_sdk_gen/managers/memberships.py index 528cc4e4..070210d5 100644 --- a/box_sdk_gen/managers/memberships.py +++ b/box_sdk_gen/managers/memberships.py @@ -10,6 +10,10 @@ from box_sdk_gen.serialization.json.serializer import deserialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from typing import List from box_sdk_gen.serialization.json.serializer import serialize @@ -201,7 +205,7 @@ def create_group_membership( group: CreateGroupMembershipGroup, *, role: Optional[CreateGroupMembershipRole] = None, - configurable_permissions: Optional[Dict[str, bool]] = None, + configurable_permissions: Union[Optional[Dict[str, bool]], NullValue] = None, fields: Optional[List[str]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> GroupMembership: @@ -226,7 +230,7 @@ def create_group_membership( 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., defaults to None - :type configurable_permissions: Optional[Dict[str, bool]], optional + :type configurable_permissions: Union[Optional[Dict[str, bool]], NullValue], 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. @@ -326,7 +330,7 @@ def update_group_membership_by_id( group_membership_id: str, *, role: Optional[UpdateGroupMembershipByIdRole] = None, - configurable_permissions: Optional[Dict[str, bool]] = None, + configurable_permissions: Union[Optional[Dict[str, bool]], NullValue] = None, fields: Optional[List[str]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> GroupMembership: @@ -353,7 +357,7 @@ def update_group_membership_by_id( 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., defaults to None - :type configurable_permissions: Optional[Dict[str, bool]], optional + :type configurable_permissions: Union[Optional[Dict[str, bool]], NullValue], 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/retention_policies.py b/box_sdk_gen/managers/retention_policies.py index dd8efa16..3a52e4d9 100644 --- a/box_sdk_gen/managers/retention_policies.py +++ b/box_sdk_gen/managers/retention_policies.py @@ -12,6 +12,10 @@ from box_sdk_gen.serialization.json.serializer import serialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.schemas.retention_policies import RetentionPolicies from box_sdk_gen.schemas.client_error import ClientError @@ -291,15 +295,17 @@ def update_retention_policy_by_id( self, retention_policy_id: str, *, - policy_name: Optional[str] = None, - description: Optional[str] = None, + policy_name: Union[Optional[str], NullValue] = None, + description: Union[Optional[str], NullValue] = None, disposition_action: Optional[str] = None, - retention_type: Optional[str] = None, + retention_type: Union[Optional[str], NullValue] = None, retention_length: Optional[str] = None, - status: Optional[str] = None, - can_owner_extend_retention: Optional[bool] = None, - are_owners_notified: Optional[bool] = None, - custom_notification_recipients: Optional[List[UserBase]] = None, + status: Union[Optional[str], NullValue] = None, + can_owner_extend_retention: Union[Optional[bool], NullValue] = None, + are_owners_notified: Union[Optional[bool], NullValue] = None, + custom_notification_recipients: Union[ + Optional[List[UserBase]], NullValue + ] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> RetentionPolicy: """ @@ -308,9 +314,9 @@ def update_retention_policy_by_id( Example: "982312" :type retention_policy_id: str :param policy_name: The name for the retention policy, defaults to None - :type policy_name: Optional[str], optional + :type policy_name: Union[Optional[str], NullValue], optional :param description: The additional text description of the retention policy., defaults to None - :type description: Optional[str], optional + :type description: Union[Optional[str], NullValue], optional :param disposition_action: The disposition action of the retention policy. This action can be `permanently_delete`, which will cause the content retained by the policy @@ -339,7 +345,7 @@ def update_retention_policy_by_id( `non-modifiable` type only. You can convert a `modifiable` policy to `non-modifiable`, but not the other way around., defaults to None - :type retention_type: Optional[str], optional + :type retention_type: Union[Optional[str], NullValue], optional :param retention_length: The length of the retention policy. This value specifies the duration in days that the retention policy will be active for after being assigned to @@ -351,17 +357,17 @@ def update_retention_policy_by_id( If not retiring a policy, do not include this parameter or set it to `null`., defaults to None - :type status: Optional[str], optional + :type status: Union[Optional[str], NullValue], optional :param can_owner_extend_retention: Determines if the owner of items under the policy can extend the retention when the original retention duration is about to end., defaults to None - :type can_owner_extend_retention: Optional[bool], optional + :type can_owner_extend_retention: Union[Optional[bool], NullValue], optional :param are_owners_notified: Determines if owners and co-owners of items under the policy are notified when the retention duration is about to end., defaults to None - :type are_owners_notified: Optional[bool], optional + :type are_owners_notified: Union[Optional[bool], NullValue], optional :param custom_notification_recipients: A list of users notified when the retention duration is about to end., defaults to None - :type custom_notification_recipients: Optional[List[UserBase]], optional + :type custom_notification_recipients: Union[Optional[List[UserBase]], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/shared_links_files.py b/box_sdk_gen/managers/shared_links_files.py index 7bb19b49..a5bf2d34 100644 --- a/box_sdk_gen/managers/shared_links_files.py +++ b/box_sdk_gen/managers/shared_links_files.py @@ -14,6 +14,10 @@ from box_sdk_gen.serialization.json.serializer import serialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.schemas.file_full import FileFull from box_sdk_gen.schemas.client_error import ClientError @@ -479,7 +483,9 @@ def remove_shared_link_from_file( file_id: str, fields: str, *, - shared_link: Optional[RemoveSharedLinkFromFileSharedLink] = None, + shared_link: Union[ + Optional[RemoveSharedLinkFromFileSharedLink], NullValue + ] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> FileFull: """ @@ -498,7 +504,7 @@ def remove_shared_link_from_file( :type fields: str :param shared_link: By setting this value to `null`, the shared link is removed from the file., defaults to None - :type shared_link: Optional[RemoveSharedLinkFromFileSharedLink], optional + :type shared_link: Union[Optional[RemoveSharedLinkFromFileSharedLink], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/shared_links_folders.py b/box_sdk_gen/managers/shared_links_folders.py index af8a33d0..cc204fb3 100644 --- a/box_sdk_gen/managers/shared_links_folders.py +++ b/box_sdk_gen/managers/shared_links_folders.py @@ -14,6 +14,10 @@ from box_sdk_gen.serialization.json.serializer import serialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.schemas.folder_full import FolderFull from box_sdk_gen.schemas.client_error import ClientError @@ -481,7 +485,9 @@ def remove_shared_link_from_folder( folder_id: str, fields: str, *, - shared_link: Optional[RemoveSharedLinkFromFolderSharedLink] = None, + shared_link: Union[ + Optional[RemoveSharedLinkFromFolderSharedLink], NullValue + ] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> FolderFull: """ @@ -503,7 +509,7 @@ def remove_shared_link_from_folder( :type fields: str :param shared_link: By setting this value to `null`, the shared link is removed from the folder., defaults to None - :type shared_link: Optional[RemoveSharedLinkFromFolderSharedLink], optional + :type shared_link: Union[Optional[RemoveSharedLinkFromFolderSharedLink], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/shared_links_web_links.py b/box_sdk_gen/managers/shared_links_web_links.py index 049d1c66..611a4500 100644 --- a/box_sdk_gen/managers/shared_links_web_links.py +++ b/box_sdk_gen/managers/shared_links_web_links.py @@ -14,6 +14,10 @@ from box_sdk_gen.serialization.json.serializer import serialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.schemas.web_link import WebLink from box_sdk_gen.schemas.client_error import ClientError @@ -452,7 +456,9 @@ def remove_shared_link_from_web_link( web_link_id: str, fields: str, *, - shared_link: Optional[RemoveSharedLinkFromWebLinkSharedLink] = None, + shared_link: Union[ + Optional[RemoveSharedLinkFromWebLinkSharedLink], NullValue + ] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> WebLink: """ @@ -465,7 +471,7 @@ def remove_shared_link_from_web_link( :type fields: str :param shared_link: By setting this value to `null`, the shared link is removed from the web link., defaults to None - :type shared_link: Optional[RemoveSharedLinkFromWebLinkSharedLink], optional + :type shared_link: Union[Optional[RemoveSharedLinkFromWebLinkSharedLink], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/shield_information_barrier_segments.py b/box_sdk_gen/managers/shield_information_barrier_segments.py index 9c09ac16..d9079e55 100644 --- a/box_sdk_gen/managers/shield_information_barrier_segments.py +++ b/box_sdk_gen/managers/shield_information_barrier_segments.py @@ -6,6 +6,10 @@ from box_sdk_gen.serialization.json.serializer import deserialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.serialization.json.serializer import serialize from box_sdk_gen.schemas.shield_information_barrier_segment import ( @@ -95,7 +99,7 @@ def update_shield_information_barrier_segment_by_id( shield_information_barrier_segment_id: str, *, name: Optional[str] = None, - description: Optional[str] = None, + description: Union[Optional[str], NullValue] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> ShieldInformationBarrierSegment: """ @@ -107,7 +111,7 @@ def update_shield_information_barrier_segment_by_id( :type name: Optional[str], optional :param description: The updated description for the shield information barrier segment., defaults to None - :type description: Optional[str], optional + :type description: Union[Optional[str], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/sign_requests.py b/box_sdk_gen/managers/sign_requests.py index 36dd3714..5c318db4 100644 --- a/box_sdk_gen/managers/sign_requests.py +++ b/box_sdk_gen/managers/sign_requests.py @@ -10,6 +10,10 @@ from typing import List +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.serialization.json.serializer import serialize from box_sdk_gen.schemas.file_base import FileBase @@ -219,23 +223,25 @@ def create_sign_request( self, signers: List[SignRequestCreateSigner], *, - source_files: Optional[List[FileBase]] = None, - signature_color: Optional[CreateSignRequestSignatureColor] = None, + source_files: Union[Optional[List[FileBase]], NullValue] = None, + signature_color: Union[ + Optional[CreateSignRequestSignatureColor], NullValue + ] = None, parent_folder: Optional[FolderMini] = None, is_document_preparation_needed: Optional[bool] = None, - redirect_url: Optional[str] = None, - declined_redirect_url: Optional[str] = None, + redirect_url: Union[Optional[str], NullValue] = None, + declined_redirect_url: Union[Optional[str], NullValue] = None, are_text_signatures_enabled: Optional[bool] = None, - email_subject: Optional[str] = None, - email_message: Optional[str] = None, + email_subject: Union[Optional[str], NullValue] = None, + email_message: Union[Optional[str], NullValue] = None, are_reminders_enabled: Optional[bool] = None, name: Optional[str] = None, prefill_tags: Optional[List[SignRequestPrefillTag]] = None, - days_valid: Optional[int] = None, - external_id: Optional[str] = None, - is_phone_verification_required_to_view: Optional[bool] = None, - template_id: Optional[str] = None, - external_system_name: Optional[str] = None, + days_valid: Union[Optional[int], NullValue] = None, + external_id: Union[Optional[str], NullValue] = None, + is_phone_verification_required_to_view: Union[Optional[bool], NullValue] = None, + template_id: Union[Optional[str], NullValue] = None, + external_system_name: Union[Optional[str], NullValue] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None ) -> SignRequest: """ @@ -253,21 +259,21 @@ def create_sign_request( Read more about [segments and ethical walls](https://support.box.com/hc/en-us/articles/9920431507603-Understanding-Information-Barriers#h_01GFVJEHQA06N7XEZ4GCZ9GFAQ). :type signers: List[SignRequestCreateSigner] :param source_files: List of files to create a signing document from. This is currently limited to ten files. Only the ID and type fields are required for each file., defaults to None - :type source_files: Optional[List[FileBase]], optional + :type source_files: Union[Optional[List[FileBase]], NullValue], optional :param signature_color: Force a specific color for the signature (blue, black, or red), defaults to None - :type signature_color: Optional[CreateSignRequestSignatureColor], optional + :type signature_color: Union[Optional[CreateSignRequestSignatureColor], NullValue], optional :param is_document_preparation_needed: Indicates if the sender should receive a `prepare_url` in the response to complete document preparation using the UI., defaults to None :type is_document_preparation_needed: Optional[bool], optional :param redirect_url: When specified, the signature request will be redirected to this url when a document is signed., defaults to None - :type redirect_url: Optional[str], optional + :type redirect_url: Union[Optional[str], NullValue], optional :param declined_redirect_url: The uri that a signer will be redirected to after declining to sign a document., defaults to None - :type declined_redirect_url: Optional[str], optional + :type declined_redirect_url: Union[Optional[str], NullValue], optional :param are_text_signatures_enabled: Disables the usage of signatures generated by typing (text)., defaults to None :type are_text_signatures_enabled: Optional[bool], optional :param email_subject: Subject of sign request email. This is cleaned by sign request. If this field is not passed, a default subject will be used., defaults to None - :type email_subject: Optional[str], optional + :type email_subject: Union[Optional[str], NullValue], optional :param email_message: Message to include in sign request email. The field is cleaned through sanitization of specific characters. However, some html tags are allowed. Links included in the message are also converted to hyperlinks in the email. The message may contain the following html tags including `a`, `abbr`, `acronym`, `b`, `blockquote`, `code`, `em`, `i`, `ul`, `li`, `ol`, and `strong`. Be aware that when the text to html ratio is too high, the email may end up in spam filters. Custom styles on these tags are not allowed. If this field is not passed, a default message will be used., defaults to None - :type email_message: Optional[str], optional + :type email_message: Union[Optional[str], NullValue], optional :param are_reminders_enabled: Reminds signers to sign a document on day 3, 8, 13 and 18. Reminders are only sent to outstanding signers., defaults to None :type are_reminders_enabled: Optional[bool], optional :param name: Name of the signature request., defaults to None @@ -275,15 +281,15 @@ def create_sign_request( :param prefill_tags: When a document contains sign-related tags in the content, you can prefill them using this `prefill_tags` by referencing the 'id' of the tag as the `external_id` field of the prefill tag., defaults to None :type prefill_tags: Optional[List[SignRequestPrefillTag]], optional :param days_valid: Set the number of days after which the created signature request will automatically expire if not completed. By default, we do not apply any expiration date on signature requests, and the signature request does not expire., defaults to None - :type days_valid: Optional[int], optional + :type days_valid: Union[Optional[int], NullValue], optional :param external_id: This can be used to reference an ID in an external system that the sign request is related to., defaults to None - :type external_id: Optional[str], optional + :type external_id: Union[Optional[str], NullValue], optional :param is_phone_verification_required_to_view: Forces signers to verify a text message prior to viewing the document. You must specify the phone number of signers to have this setting apply to them., defaults to None - :type is_phone_verification_required_to_view: Optional[bool], optional + :type is_phone_verification_required_to_view: Union[Optional[bool], NullValue], optional :param template_id: When a signature request is created from a template this field will indicate the id of that template., defaults to None - :type template_id: Optional[str], optional + :type template_id: Union[Optional[str], NullValue], optional :param external_system_name: Used as an optional system name to appear in the signature log next to the signers who have been assigned the `embed_url_external_id`., defaults to None - :type external_system_name: Optional[str], optional + :type external_system_name: Union[Optional[str], NullValue], optional :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None :type extra_headers: Optional[Dict[str, Optional[str]]], optional """ diff --git a/box_sdk_gen/managers/users.py b/box_sdk_gen/managers/users.py index d6c7d221..45112e1c 100644 --- a/box_sdk_gen/managers/users.py +++ b/box_sdk_gen/managers/users.py @@ -14,6 +14,10 @@ from box_sdk_gen.serialization.json.serializer import serialize +from box_sdk_gen.internal.null_value import NullValue + +from typing import Union + from box_sdk_gen.schemas.users import Users from box_sdk_gen.schemas.client_error import ClientError @@ -476,7 +480,7 @@ def update_user_by_id( self, user_id: str, *, - enterprise: Optional[str] = None, + enterprise: Union[Optional[str], NullValue] = None, notify: Optional[bool] = None, name: Optional[str] = None, login: Optional[str] = None, @@ -495,7 +499,9 @@ def update_user_by_id( is_password_reset_required: Optional[bool] = None, status: Optional[UpdateUserByIdStatus] = None, space_amount: Optional[int] = None, - notification_email: Optional[UpdateUserByIdNotificationEmail] = None, + notification_email: Union[ + Optional[UpdateUserByIdNotificationEmail], NullValue + ] = None, external_app_user_id: Optional[str] = None, fields: Optional[List[str]] = None, extra_headers: Optional[Dict[str, Optional[str]]] = None @@ -513,7 +519,7 @@ def update_user_by_id( :type user_id: str :param enterprise: Set this to `null` to roll the user out of the enterprise and make them a free user, defaults to None - :type enterprise: Optional[str], optional + :type enterprise: Union[Optional[str], NullValue], optional :param notify: Whether the user should receive an email when they are rolled out of an enterprise, defaults to None :type notify: Optional[bool], optional @@ -567,7 +573,7 @@ def update_user_by_id( to the primary email address. Set this value to `null` to remove the notification email., defaults to None - :type notification_email: Optional[UpdateUserByIdNotificationEmail], optional + :type notification_email: Union[Optional[UpdateUserByIdNotificationEmail], NullValue], optional :param external_app_user_id: An external identifier for an app user, which can be used to look up the user. This can be used to tie user IDs from external identity providers to Box users. diff --git a/docs/file_versions.md b/docs/file_versions.md index 18aab762..6c03deaa 100644 --- a/docs/file_versions.md +++ b/docs/file_versions.md @@ -57,7 +57,11 @@ See the endpoint docs at ```python -client.file_versions.get_file_version_by_id(file.id, file_versions.entries[0].id) +client.file_versions.get_file_version_by_id( + file.id, + file_versions.entries[0].id, + fields=["trashed_at", "trashed_by", "restored_at", "restored_by"], +) ``` ### Arguments @@ -93,7 +97,13 @@ This operation is performed by calling function `update_file_version_by_id`. See the endpoint docs at [API Reference](https://developer.box.com/reference/put-files-id-versions-id/). -_Currently we don't have an example for calling `update_file_version_by_id` in integration tests_ + + +```python +client.file_versions.update_file_version_by_id( + file.id, file_version.id, trashed_at=create_null() +) +``` ### Arguments @@ -126,9 +136,7 @@ See the endpoint docs at ```python -client.file_versions.delete_file_version_by_id( - file.id, file_versions_restored.entries[0].id -) +client.file_versions.delete_file_version_by_id(file.id, file_version.id) ``` ### Arguments diff --git a/docs/users.md b/docs/users.md index 9871da77..c1275932 100644 --- a/docs/users.md +++ b/docs/users.md @@ -216,7 +216,7 @@ See the endpoint docs at ```python -client.users.update_user_by_id(user.id, name=updated_user_name) +client.users.update_user_by_id(user.id, notification_email=create_null()) ``` ### Arguments diff --git a/test/file_versions.py b/test/file_versions.py index b0ba8267..f10f7f42 100644 --- a/test/file_versions.py +++ b/test/file_versions.py @@ -20,12 +20,14 @@ from box_sdk_gen.internal.utils import generate_byte_stream +from box_sdk_gen.internal.utils import create_null + from test.commons import get_default_client client: BoxClient = get_default_client() -def testCreateListGetRestoreDeleteFileVersion(): +def testCreateListGetPromoteFileVersion(): old_name: str = get_uuid() new_name: str = get_uuid() files: Files = client.uploads.upload_file( @@ -54,14 +56,60 @@ def testCreateListGetRestoreDeleteFileVersion(): id=file_versions.entries[0].id, type=PromoteFileVersionType.FILE_VERSION.value, ) - file_restored: FileFull = client.files.get_file_by_id(file.id) - assert file_restored.name == old_name - assert file_restored.size == 10 - file_versions_restored: FileVersions = client.file_versions.get_file_versions( - file.id + file_with_promoted_version: FileFull = client.files.get_file_by_id(file.id) + assert file_with_promoted_version.name == old_name + assert file_with_promoted_version.size == 10 + client.file_versions.delete_file_version_by_id(file.id, file_version.id) + client.files.delete_file_by_id(file.id) + + +def testRemoveAndRestoreFileVersion(): + old_name: str = get_uuid() + new_name: str = get_uuid() + files: Files = client.uploads.upload_file( + UploadFileAttributes( + name=old_name, parent=UploadFileAttributesParentField(id='0') + ), + generate_byte_stream(10), + ) + file: FileFull = files.entries[0] + client.uploads.upload_file_version( + file.id, UploadFileVersionAttributes(name=new_name), generate_byte_stream(20) + ) + file_versions: FileVersions = client.file_versions.get_file_versions(file.id) + assert file_versions.total_count == 1 + file_version: FileVersionFull = client.file_versions.get_file_version_by_id( + file.id, + file_versions.entries[0].id, + fields=['trashed_at', 'trashed_by', 'restored_at', 'restored_by'], + ) + assert file_version.trashed_at == None + assert file_version.trashed_by == None + assert file_version.restored_at == None + assert file_version.restored_by == None + client.file_versions.delete_file_version_by_id(file.id, file_version.id) + deleted_file_version: FileVersionFull = client.file_versions.get_file_version_by_id( + file.id, + file_versions.entries[0].id, + fields=['trashed_at', 'trashed_by', 'restored_at', 'restored_by'], + ) + assert not deleted_file_version.trashed_at == None + assert not deleted_file_version.trashed_by == None + assert deleted_file_version.restored_at == None + assert deleted_file_version.restored_by == None + client.file_versions.update_file_version_by_id( + file.id, file_version.id, trashed_at=create_null() ) - client.file_versions.delete_file_version_by_id( - file.id, file_versions_restored.entries[0].id + restored_file_version: FileVersionFull = ( + client.file_versions.get_file_version_by_id( + file.id, + file_versions.entries[0].id, + fields=['trashed_at', 'trashed_by', 'restored_at', 'restored_by'], + ) ) - client.file_versions.get_file_versions(file.id) + assert restored_file_version.trashed_at == None + assert restored_file_version.trashed_by == None + assert not restored_file_version.restored_at == None + assert not restored_file_version.restored_by == None + client.file_versions.delete_file_version_by_id(file.id, file_version.id) client.files.delete_file_by_id(file.id) diff --git a/test/files.py b/test/files.py index 916191d9..ab8391a9 100644 --- a/test/files.py +++ b/test/files.py @@ -14,6 +14,10 @@ from box_sdk_gen.schemas.trash_file import TrashFile +from box_sdk_gen.managers.files import UpdateFileByIdLock + +from box_sdk_gen.managers.files import UpdateFileByIdLockAccessField + from box_sdk_gen.managers.files import CopyFileParent from box_sdk_gen.internal.utils import get_uuid @@ -26,6 +30,8 @@ from box_sdk_gen.internal.utils import ByteStream +from box_sdk_gen.internal.utils import create_null + from test.commons import upload_new_file from test.commons import get_default_client @@ -105,6 +111,21 @@ def testUpdateFile(): client.files.delete_file_by_id(updated_file.id) +def testFileLock(): + file: FileFull = upload_new_file() + file_with_lock: FileFull = client.files.update_file_by_id( + file.id, + lock=UpdateFileByIdLock(access=UpdateFileByIdLockAccessField.LOCK.value), + fields=['lock'], + ) + assert not file_with_lock.lock == None + file_without_lock: FileFull = client.files.update_file_by_id( + file.id, lock=create_null(), fields=['lock'] + ) + assert file_without_lock.lock == None + client.files.delete_file_by_id(file.id) + + def testCopyFile(): file_origin: FileFull = upload_new_file() copied_file_name: str = get_uuid() diff --git a/test/users.py b/test/users.py index 28cf3845..6b1cbf39 100644 --- a/test/users.py +++ b/test/users.py @@ -6,8 +6,12 @@ from box_sdk_gen.schemas.user_full import UserFull +from box_sdk_gen.managers.users import UpdateUserByIdNotificationEmail + from box_sdk_gen.internal.utils import get_uuid +from box_sdk_gen.internal.utils import create_null + from test.commons import get_default_client client: BoxClient = get_default_client() @@ -38,3 +42,20 @@ def test_create_update_get_delete_user(): ) assert updated_user.name == updated_user_name client.users.delete_user_by_id(user.id) + + +def test_user_notification_email(): + user_name: str = get_uuid() + user_login: str = ''.join([get_uuid(), '@gmail.com']) + user: UserFull = client.users.create_user( + user_name, login=user_login, is_platform_access_only=True + ) + updated_with_notification_email: UserFull = client.users.update_user_by_id( + user.id, notification_email=UpdateUserByIdNotificationEmail(email=user_login) + ) + assert not updated_with_notification_email.notification_email == None + updated_without_notification_email: UserFull = client.users.update_user_by_id( + user.id, notification_email=create_null() + ) + assert updated_without_notification_email.notification_email == None + client.users.delete_user_by_id(user.id)