From c723a79cfe025db0053d94ccd0240799316215d0 Mon Sep 17 00:00:00 2001 From: dvacca-onfido <134616519+dvacca-onfido@users.noreply.github.com> Date: Thu, 20 Feb 2025 08:44:58 +0000 Subject: [PATCH 1/2] Upgrade after onfido-openapi-spec change db5a1b5 --- .openapi-generator/VERSION | 2 +- .release.json | 6 +- README.md | 4 +- onfido/api_client.py | 2 +- onfido/configuration.py | 188 ++++++++++++++---- onfido/exceptions.py | 17 ++ onfido/models/applicant_consent_name.py | 1 + onfido/models/check.py | 4 +- onfido/models/check_response.py | 4 +- onfido/models/check_status.py | 1 + onfido/models/country_codes.py | 1 + ...ntelligence_breakdown_properties_device.py | 20 +- onfido/models/document.py | 4 +- onfido/models/document_properties.py | 12 +- onfido/models/document_shared.py | 4 +- onfido/models/document_types.py | 1 + ...r_verification_report_all_of_properties.py | 12 +- .../extraction_document_classification.py | 4 +- onfido/models/extraction_extracted_data.py | 4 +- onfido/models/id_number.py | 4 +- onfido/models/proof_of_address_properties.py | 4 +- ...eat_attempts_list_repeat_attempts_inner.py | 12 +- onfido/models/report_name.py | 1 + onfido/models/report_result.py | 1 + onfido/models/report_status.py | 1 + onfido/models/report_sub_result.py | 1 + onfido/models/results_feedback.py | 4 +- onfido/models/us_driving_licence_builder.py | 12 +- onfido/models/us_driving_licence_shared.py | 12 +- onfido/models/watchlist_monitor.py | 4 +- onfido/models/watchlist_monitor_builder.py | 4 +- onfido/models/watchlist_monitor_shared.py | 4 +- onfido/models/webhook_event_object_status.py | 1 + onfido/models/webhook_event_resource_type.py | 1 + onfido/models/webhook_event_type.py | 1 + onfido/models/workflow_run_link.py | 4 +- onfido/models/workflow_run_status.py | 1 + poetry.lock | 2 +- pyproject.toml | 21 +- 39 files changed, 272 insertions(+), 114 deletions(-) diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 4bc5d61..b23eb27 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -7.9.0 +7.11.0 diff --git a/.release.json b/.release.json index cf84c29..4971d03 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "0eec622", - "long_sha": "0eec6225e66b9f905dac23fe4eb18a1584517f64", - "version": "" + "short_sha": "db5a1b5", + "long_sha": "db5a1b59681fa467b324b4116de24d88d56d7452", + "version": "v5.0.0" }, "release": "v5.0.0" } diff --git a/README.md b/README.md index db58a34..68ae0cf 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This version uses Onfido API v3.6. Refer to our [API versioning guide](https://d ### Requirements -Python 3.7+ +Python 3.8+ ### Installation @@ -119,7 +119,7 @@ Except for accessing Task object's outputs, avoid using the `additional_properti ## Contributing -This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) (version: 7.9.0); therefore, all contributions (except test files) should target the [Onfido OpenAPI specification repository](https://github.com/onfido/onfido-openapi-spec/tree/master) instead of this repository. Please follow the contribution guidelines provided in the OpenAPI specification repository. +This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) (version: 7.11.0); therefore, all contributions (except test files) should target the [Onfido OpenAPI specification repository](https://github.com/onfido/onfido-openapi-spec/tree/master) instead of this repository. Please follow the contribution guidelines provided in the OpenAPI specification repository. For contributions to the tests instead, please follow the steps below: diff --git a/onfido/api_client.py b/onfido/api_client.py index 18c1452..19e8049 100644 --- a/onfido/api_client.py +++ b/onfido/api_client.py @@ -517,7 +517,7 @@ def parameters_to_url_query(self, params, collection_formats): if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, str(value)) for value in v) + new_params.extend((k, quote(str(value))) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/onfido/configuration.py b/onfido/configuration.py index 521b974..d4bcef4 100644 --- a/onfido/configuration.py +++ b/onfido/configuration.py @@ -13,14 +13,15 @@ import copy +import http.client as httplib import logging from logging import FileHandler import multiprocessing import sys -from typing import Optional -import urllib3 +from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict +from typing_extensions import NotRequired, Self -import http.client as httplib +import urllib3 from enum import Enum @@ -37,6 +38,107 @@ class Region(Enum): 'minLength', 'pattern', 'maxItems', 'minItems' } +ServerVariablesT = Dict[str, str] + +GenericAuthSetting = TypedDict( + "GenericAuthSetting", + { + "type": str, + "in": str, + "key": str, + "value": str, + }, +) + + +OAuth2AuthSetting = TypedDict( + "OAuth2AuthSetting", + { + "type": Literal["oauth2"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +APIKeyAuthSetting = TypedDict( + "APIKeyAuthSetting", + { + "type": Literal["api_key"], + "in": str, + "key": str, + "value": Optional[str], + }, +) + + +BasicAuthSetting = TypedDict( + "BasicAuthSetting", + { + "type": Literal["basic"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": Optional[str], + }, +) + + +BearerFormatAuthSetting = TypedDict( + "BearerFormatAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "format": Literal["JWT"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +BearerAuthSetting = TypedDict( + "BearerAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +HTTPSignatureAuthSetting = TypedDict( + "HTTPSignatureAuthSetting", + { + "type": Literal["http-signature"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": None, + }, +) + + +AuthSettings = TypedDict( + "AuthSettings", + { + "Token": APIKeyAuthSetting, + }, + total=False, +) + + +class HostSettingVariable(TypedDict): + description: str + default_value: str + enum_values: List[str] + + +class HostSetting(TypedDict): + url: str + description: str + variables: NotRequired[Dict[str, HostSettingVariable]] + + class Configuration: """This class contains various settings of the API client. @@ -76,20 +178,23 @@ class Configuration: Cookie: JSESSIONID abc123 """ - _default = None - - def __init__(self, host=None, - api_token=None, - region=Region.EU, - timeout=None, - server_index=None, - server_operation_index=None, server_operation_variables=None, - ignore_operation_servers=False, - ssl_ca_cert=None, - retries=None, - *, - debug: Optional[bool] = None - ) -> None: + _default: ClassVar[Optional[Self]] = None + + def __init__( + self, + host: Optional[str]=None, + api_token: Optional[str]=None, + region: Optional[Region]=Region.EU, + timeout: Optional[urllib3.util.Timeout]=None, + server_index: Optional[int]=None, + server_operation_index: Optional[Dict[int, int]]=None, + server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None, + ignore_operation_servers: bool=False, + ssl_ca_cert: Optional[str]=None, + retries: Optional[int] = None, + *, + debug: Optional[bool] = None, + ) -> None: """Constructor """ self._base_path = "https://api.eu.onfido.com/v3.6" if host is None else host @@ -199,7 +304,7 @@ def __init__(self, host=None, """date format """ - def __deepcopy__(self, memo): + def __deepcopy__(self, memo: Dict[int, Any]) -> Self: cls = self.__class__ result = cls.__new__(cls) memo[id(self)] = result @@ -213,11 +318,11 @@ def __deepcopy__(self, memo): result.debug = self.debug return result - def __setattr__(self, name, value): + def __setattr__(self, name: str, value: Any) -> None: object.__setattr__(self, name, value) @classmethod - def set_default(cls, default): + def set_default(cls, default: Optional[Self]) -> None: """Set default instance of configuration. It stores default configuration, which can be @@ -228,7 +333,7 @@ def set_default(cls, default): cls._default = default @classmethod - def get_default_copy(cls): + def get_default_copy(cls) -> Self: """Deprecated. Please use `get_default` instead. Deprecated. Please use `get_default` instead. @@ -238,7 +343,7 @@ def get_default_copy(cls): return cls.get_default() @classmethod - def get_default(cls): + def get_default(cls) -> Self: """Return the default configuration. This method returns newly created, based on default constructor, @@ -248,11 +353,11 @@ def get_default(cls): :return: The configuration object. """ if cls._default is None: - cls._default = Configuration() + cls._default = cls() return cls._default @property - def logger_file(self): + def logger_file(self) -> Optional[str]: """The logger file. If the logger_file is None, then add stream handler and remove file @@ -264,7 +369,7 @@ def logger_file(self): return self.__logger_file @logger_file.setter - def logger_file(self, value): + def logger_file(self, value: Optional[str]) -> None: """The logger file. If the logger_file is None, then add stream handler and remove file @@ -283,7 +388,7 @@ def logger_file(self, value): logger.addHandler(self.logger_file_handler) @property - def debug(self): + def debug(self) -> bool: """Debug status :param value: The debug status, True or False. @@ -292,7 +397,7 @@ def debug(self): return self.__debug @debug.setter - def debug(self, value): + def debug(self, value: bool) -> None: """Debug status :param value: The debug status, True or False. @@ -314,7 +419,7 @@ def debug(self, value): httplib.HTTPConnection.debuglevel = 0 @property - def logger_format(self): + def logger_format(self) -> str: """The logger format. The logger_formatter will be updated when sets logger_format. @@ -325,7 +430,7 @@ def logger_format(self): return self.__logger_format @logger_format.setter - def logger_format(self, value): + def logger_format(self, value: str) -> None: """The logger format. The logger_formatter will be updated when sets logger_format. @@ -336,7 +441,7 @@ def logger_format(self, value): self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier, alias=None): + def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]: """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. @@ -353,7 +458,9 @@ def get_api_key_with_prefix(self, identifier, alias=None): else: return key - def get_basic_auth_token(self): + return None + + def get_basic_auth_token(self) -> Optional[str]: """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. @@ -368,12 +475,12 @@ def get_basic_auth_token(self): basic_auth=username + ':' + password ).get('authorization') - def auth_settings(self): + def auth_settings(self)-> AuthSettings: """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ - auth = {} + auth: AuthSettings = {} if 'Token' in self.api_key: auth['Token'] = { 'type': 'api_key', @@ -385,7 +492,7 @@ def auth_settings(self): } return auth - def to_debug_report(self): + def to_debug_report(self) -> str: """Gets the essential information for debugging. :return: The report for debugging. @@ -397,7 +504,7 @@ def to_debug_report(self): "SDK Package Version: 5.0.0".\ format(env=sys.platform, pyversion=sys.version) - def get_host_settings(self): + def get_host_settings(self) -> List[HostSetting]: """Gets an array of host settings :return: An array of host settings @@ -420,7 +527,12 @@ def get_host_settings(self): } ] - def get_host_from_settings(self, index, variables=None, servers=None): + def get_host_from_settings( + self, + index: Optional[int], + variables: Optional[ServerVariablesT]=None, + servers: Optional[List[HostSetting]]=None, + ) -> str: """Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value @@ -460,12 +572,12 @@ def get_host_from_settings(self, index, variables=None, servers=None): return url @property - def host(self): + def host(self) -> str: """Return generated host.""" return self.get_host_from_settings(self.server_index, variables=self.server_variables) @host.setter - def host(self, value): + def host(self, value: str) -> None: """Fix base path.""" self._base_path = value self.server_index = None diff --git a/onfido/exceptions.py b/onfido/exceptions.py index 8bc96db..3c7dde4 100644 --- a/onfido/exceptions.py +++ b/onfido/exceptions.py @@ -150,6 +150,13 @@ def from_response( if http_resp.status == 404: raise NotFoundException(http_resp=http_resp, body=body, data=data) + # Added new conditions for 409 and 422 + if http_resp.status == 409: + raise ConflictException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 422: + raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data) + if 500 <= http_resp.status <= 599: raise ServiceException(http_resp=http_resp, body=body, data=data) raise ApiException(http_resp=http_resp, body=body, data=data) @@ -188,6 +195,16 @@ class ServiceException(ApiException): pass +class ConflictException(ApiException): + """Exception for HTTP 409 Conflict.""" + pass + + +class UnprocessableEntityException(ApiException): + """Exception for HTTP 422 Unprocessable Entity.""" + pass + + def render_path(path_to_item): """Returns a string representation of a path""" result = "" diff --git a/onfido/models/applicant_consent_name.py b/onfido/models/applicant_consent_name.py index 34e8a63..872ae81 100644 --- a/onfido/models/applicant_consent_name.py +++ b/onfido/models/applicant_consent_name.py @@ -29,6 +29,7 @@ class ApplicantConsentName(str, Enum): PRIVACY_NOTICES_READ = 'privacy_notices_read' SSN_VERIFICATION = 'ssn_verification' PHONE_NUMBER_VERIFICATION = 'phone_number_verification' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/check.py b/onfido/models/check.py index d8d763f..f48a92f 100644 --- a/onfido/models/check.py +++ b/onfido/models/check.py @@ -54,8 +54,8 @@ def result_validate_enum(cls, value): if value is None: return value - if value not in set(['clear', 'consider']): - raise ValueError("must be one of enum values ('clear', 'consider')") + if value not in set(['clear', 'consider', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('clear', 'consider', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/check_response.py b/onfido/models/check_response.py index 6c985e8..111cc75 100644 --- a/onfido/models/check_response.py +++ b/onfido/models/check_response.py @@ -47,8 +47,8 @@ def result_validate_enum(cls, value): if value is None: return value - if value not in set(['clear', 'consider']): - raise ValueError("must be one of enum values ('clear', 'consider')") + if value not in set(['clear', 'consider', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('clear', 'consider', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/check_status.py b/onfido/models/check_status.py index 72b2f7f..670508b 100644 --- a/onfido/models/check_status.py +++ b/onfido/models/check_status.py @@ -32,6 +32,7 @@ class CheckStatus(str, Enum): WITHDRAWN = 'withdrawn' PAUSED = 'paused' REOPENED = 'reopened' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/country_codes.py b/onfido/models/country_codes.py index fe53b85..ed17ea5 100644 --- a/onfido/models/country_codes.py +++ b/onfido/models/country_codes.py @@ -276,6 +276,7 @@ class CountryCodes(str, Enum): ZAF = 'ZAF' ZMB = 'ZMB' ZWE = 'ZWE' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/device_intelligence_breakdown_properties_device.py b/onfido/models/device_intelligence_breakdown_properties_device.py index 4925285..9d167b7 100644 --- a/onfido/models/device_intelligence_breakdown_properties_device.py +++ b/onfido/models/device_intelligence_breakdown_properties_device.py @@ -49,8 +49,8 @@ def sdk_source_validate_enum(cls, value): if value is None: return value - if value not in set(['onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk']): - raise ValueError("must be one of enum values ('onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk')") + if value not in set(['onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk', 'unknown_default_open_api')") return value @field_validator('authentication_type') @@ -59,8 +59,8 @@ def authentication_type_validate_enum(cls, value): if value is None: return value - if value not in set(['sdk_token', 'mobile_token', 'api_token']): - raise ValueError("must be one of enum values ('sdk_token', 'mobile_token', 'api_token')") + if value not in set(['sdk_token', 'mobile_token', 'api_token', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('sdk_token', 'mobile_token', 'api_token', 'unknown_default_open_api')") return value @field_validator('ip_reputation') @@ -69,8 +69,8 @@ def ip_reputation_validate_enum(cls, value): if value is None: return value - if value not in set(['NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK']): - raise ValueError("must be one of enum values ('NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK')") + if value not in set(['NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK', 'unknown_default_open_api')") return value @field_validator('document_capture') @@ -79,8 +79,8 @@ def document_capture_validate_enum(cls, value): if value is None: return value - if value not in set(['live', 'unknown_method']): - raise ValueError("must be one of enum values ('live', 'unknown_method')") + if value not in set(['live', 'unknown_method', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('live', 'unknown_method', 'unknown_default_open_api')") return value @field_validator('biometric_capture') @@ -89,8 +89,8 @@ def biometric_capture_validate_enum(cls, value): if value is None: return value - if value not in set(['live', 'unknown_method']): - raise ValueError("must be one of enum values ('live', 'unknown_method')") + if value not in set(['live', 'unknown_method', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('live', 'unknown_method', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/document.py b/onfido/models/document.py index c808484..37c5aad 100644 --- a/onfido/models/document.py +++ b/onfido/models/document.py @@ -49,8 +49,8 @@ def side_validate_enum(cls, value): if value is None: return value - if value not in set(['front', 'back']): - raise ValueError("must be one of enum values ('front', 'back')") + if value not in set(['front', 'back', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('front', 'back', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/document_properties.py b/onfido/models/document_properties.py index 1bb512e..b3a08a6 100644 --- a/onfido/models/document_properties.py +++ b/onfido/models/document_properties.py @@ -88,8 +88,8 @@ def nist_identity_evidence_strength_validate_enum(cls, value): if value is None: return value - if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength']): - raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength')") + if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength', 'unknown_default_open_api')") return value @field_validator('has_issuance_confirmation') @@ -98,8 +98,8 @@ def has_issuance_confirmation_validate_enum(cls, value): if value is None: return value - if value not in set(['true', 'false', 'unspecified']): - raise ValueError("must be one of enum values ('true', 'false', 'unspecified')") + if value not in set(['true', 'false', 'unspecified', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('true', 'false', 'unspecified', 'unknown_default_open_api')") return value @field_validator('security_tier') @@ -108,8 +108,8 @@ def security_tier_validate_enum(cls, value): if value is None: return value - if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier']): - raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier')") + if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/document_shared.py b/onfido/models/document_shared.py index 834ed38..b5691b0 100644 --- a/onfido/models/document_shared.py +++ b/onfido/models/document_shared.py @@ -42,8 +42,8 @@ def side_validate_enum(cls, value): if value is None: return value - if value not in set(['front', 'back']): - raise ValueError("must be one of enum values ('front', 'back')") + if value not in set(['front', 'back', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('front', 'back', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/document_types.py b/onfido/models/document_types.py index b87c0b2..f17934d 100644 --- a/onfido/models/document_types.py +++ b/onfido/models/document_types.py @@ -102,6 +102,7 @@ class DocumentTypes(str, Enum): IDENTITY_DOCUMENT_WITH_ADDRESS = 'identity_document_with_address' EXCHANGE_HOUSE_STATEMENT = 'exchange_house_statement' ACCOMMODATION_TENANCY_CERTIFICATE = 'accommodation_tenancy_certificate' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/document_with_driver_verification_report_all_of_properties.py b/onfido/models/document_with_driver_verification_report_all_of_properties.py index 2a6c8a5..be95946 100644 --- a/onfido/models/document_with_driver_verification_report_all_of_properties.py +++ b/onfido/models/document_with_driver_verification_report_all_of_properties.py @@ -96,8 +96,8 @@ def nist_identity_evidence_strength_validate_enum(cls, value): if value is None: return value - if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength']): - raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength')") + if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength', 'unknown_default_open_api')") return value @field_validator('has_issuance_confirmation') @@ -106,8 +106,8 @@ def has_issuance_confirmation_validate_enum(cls, value): if value is None: return value - if value not in set(['true', 'false', 'unspecified']): - raise ValueError("must be one of enum values ('true', 'false', 'unspecified')") + if value not in set(['true', 'false', 'unspecified', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('true', 'false', 'unspecified', 'unknown_default_open_api')") return value @field_validator('security_tier') @@ -116,8 +116,8 @@ def security_tier_validate_enum(cls, value): if value is None: return value - if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier']): - raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier')") + if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/extraction_document_classification.py b/onfido/models/extraction_document_classification.py index 5d7b08f..24a4376 100644 --- a/onfido/models/extraction_document_classification.py +++ b/onfido/models/extraction_document_classification.py @@ -42,8 +42,8 @@ def subtype_validate_enum(cls, value): if value is None: return value - if value not in set(['full', 'not_full', 'provisional']): - raise ValueError("must be one of enum values ('full', 'not_full', 'provisional')") + if value not in set(['full', 'not_full', 'provisional', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('full', 'not_full', 'provisional', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/extraction_extracted_data.py b/onfido/models/extraction_extracted_data.py index 653f56b..15f0881 100644 --- a/onfido/models/extraction_extracted_data.py +++ b/onfido/models/extraction_extracted_data.py @@ -66,8 +66,8 @@ def gender_validate_enum(cls, value): if value is None: return value - if value not in set(['Male', 'Female']): - raise ValueError("must be one of enum values ('Male', 'Female')") + if value not in set(['Male', 'Female', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('Male', 'Female', 'unknown_default_open_api')") return value @field_validator('nationality') diff --git a/onfido/models/id_number.py b/onfido/models/id_number.py index 6cf0ae9..fdcdaa4 100644 --- a/onfido/models/id_number.py +++ b/onfido/models/id_number.py @@ -38,8 +38,8 @@ def type_validate_enum(cls, value): if value is None: return value - if value not in set(['ssn', 'social_insurance', 'tax_id', 'identity_card', 'driving_license', 'driving_licence', 'share_code', 'voter_id', 'passport', 'other']): - raise ValueError("must be one of enum values ('ssn', 'social_insurance', 'tax_id', 'identity_card', 'driving_license', 'driving_licence', 'share_code', 'voter_id', 'passport', 'other')") + if value not in set(['ssn', 'social_insurance', 'tax_id', 'identity_card', 'driving_license', 'driving_licence', 'share_code', 'voter_id', 'passport', 'other', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('ssn', 'social_insurance', 'tax_id', 'identity_card', 'driving_license', 'driving_licence', 'share_code', 'voter_id', 'passport', 'other', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/proof_of_address_properties.py b/onfido/models/proof_of_address_properties.py index 2b75ef0..cef664b 100644 --- a/onfido/models/proof_of_address_properties.py +++ b/onfido/models/proof_of_address_properties.py @@ -44,8 +44,8 @@ def document_type_validate_enum(cls, value): if value is None: return value - if value not in set(['bank_building_society_statement', 'utility_bill', 'council_tax', 'benefit_letters', 'mortgage_statement', 'mobile_phone_bill', 'general_letter', 'insurance_statement', 'pension_property_statement_letter', 'identity_document_with_address', 'exchange_house_statement']): - raise ValueError("must be one of enum values ('bank_building_society_statement', 'utility_bill', 'council_tax', 'benefit_letters', 'mortgage_statement', 'mobile_phone_bill', 'general_letter', 'insurance_statement', 'pension_property_statement_letter', 'identity_document_with_address', 'exchange_house_statement')") + if value not in set(['bank_building_society_statement', 'utility_bill', 'council_tax', 'benefit_letters', 'mortgage_statement', 'mobile_phone_bill', 'general_letter', 'insurance_statement', 'pension_property_statement_letter', 'identity_document_with_address', 'exchange_house_statement', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('bank_building_society_statement', 'utility_bill', 'council_tax', 'benefit_letters', 'mortgage_statement', 'mobile_phone_bill', 'general_letter', 'insurance_statement', 'pension_property_statement_letter', 'identity_document_with_address', 'exchange_house_statement', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/repeat_attempts_list_repeat_attempts_inner.py b/onfido/models/repeat_attempts_list_repeat_attempts_inner.py index 8d9c903..a10d0d6 100644 --- a/onfido/models/repeat_attempts_list_repeat_attempts_inner.py +++ b/onfido/models/repeat_attempts_list_repeat_attempts_inner.py @@ -43,8 +43,8 @@ def date_of_birth_validate_enum(cls, value): if value is None: return value - if value not in set(['match', 'mismatch']): - raise ValueError("must be one of enum values ('match', 'mismatch')") + if value not in set(['match', 'mismatch', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('match', 'mismatch', 'unknown_default_open_api')") return value @field_validator('names') @@ -53,8 +53,8 @@ def names_validate_enum(cls, value): if value is None: return value - if value not in set(['match', 'mismatch']): - raise ValueError("must be one of enum values ('match', 'mismatch')") + if value not in set(['match', 'mismatch', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('match', 'mismatch', 'unknown_default_open_api')") return value @field_validator('result') @@ -63,8 +63,8 @@ def result_validate_enum(cls, value): if value is None: return value - if value not in set(['clear', 'consider']): - raise ValueError("must be one of enum values ('clear', 'consider')") + if value not in set(['clear', 'consider', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('clear', 'consider', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/report_name.py b/onfido/models/report_name.py index 71c6bc7..d7dc58d 100644 --- a/onfido/models/report_name.py +++ b/onfido/models/report_name.py @@ -47,6 +47,7 @@ class ReportName(str, Enum): US_DRIVING_LICENCE = 'us_driving_licence' DEVICE_INTELLIGENCE = 'device_intelligence' INDIA_PAN = 'india_pan' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/report_result.py b/onfido/models/report_result.py index 26b2b2a..2a3a098 100644 --- a/onfido/models/report_result.py +++ b/onfido/models/report_result.py @@ -29,6 +29,7 @@ class ReportResult(str, Enum): CLEAR = 'clear' CONSIDER = 'consider' UNIDENTIFIED = 'unidentified' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/report_status.py b/onfido/models/report_status.py index d08e349..1cd686f 100644 --- a/onfido/models/report_status.py +++ b/onfido/models/report_status.py @@ -31,6 +31,7 @@ class ReportStatus(str, Enum): CANCELLED = 'cancelled' COMPLETE = 'complete' WITHDRAWN = 'withdrawn' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/report_sub_result.py b/onfido/models/report_sub_result.py index 189b225..8fc3ffe 100644 --- a/onfido/models/report_sub_result.py +++ b/onfido/models/report_sub_result.py @@ -30,6 +30,7 @@ class ReportSubResult(str, Enum): REJECTED = 'rejected' SUSPECTED = 'suspected' CAUTION = 'caution' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/results_feedback.py b/onfido/models/results_feedback.py index 66d190d..86502d4 100644 --- a/onfido/models/results_feedback.py +++ b/onfido/models/results_feedback.py @@ -39,8 +39,8 @@ def expected_result_validate_enum(cls, value): if value is None: return value - if value not in set(['clear', 'consider']): - raise ValueError("must be one of enum values ('clear', 'consider')") + if value not in set(['clear', 'consider', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('clear', 'consider', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/us_driving_licence_builder.py b/onfido/models/us_driving_licence_builder.py index 3695458..38b8944 100644 --- a/onfido/models/us_driving_licence_builder.py +++ b/onfido/models/us_driving_licence_builder.py @@ -62,8 +62,8 @@ def document_category_validate_enum(cls, value): if value is None: return value - if value not in set(['driver license', 'driver permit', 'id card']): - raise ValueError("must be one of enum values ('driver license', 'driver permit', 'id card')") + if value not in set(['driver license', 'driver permit', 'id card', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('driver license', 'driver permit', 'id card', 'unknown_default_open_api')") return value @field_validator('eye_color_code') @@ -72,8 +72,8 @@ def eye_color_code_validate_enum(cls, value): if value is None: return value - if value not in set(['BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK']): - raise ValueError("must be one of enum values ('BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK')") + if value not in set(['BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK', 'unknown_default_open_api')") return value @field_validator('gender') @@ -82,8 +82,8 @@ def gender_validate_enum(cls, value): if value is None: return value - if value not in set(['Male', 'Female']): - raise ValueError("must be one of enum values ('Male', 'Female')") + if value not in set(['Male', 'Female', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('Male', 'Female', 'unknown_default_open_api')") return value @field_validator('state') diff --git a/onfido/models/us_driving_licence_shared.py b/onfido/models/us_driving_licence_shared.py index 80dafcf..cf46793 100644 --- a/onfido/models/us_driving_licence_shared.py +++ b/onfido/models/us_driving_licence_shared.py @@ -62,8 +62,8 @@ def document_category_validate_enum(cls, value): if value is None: return value - if value not in set(['driver license', 'driver permit', 'id card']): - raise ValueError("must be one of enum values ('driver license', 'driver permit', 'id card')") + if value not in set(['driver license', 'driver permit', 'id card', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('driver license', 'driver permit', 'id card', 'unknown_default_open_api')") return value @field_validator('eye_color_code') @@ -72,8 +72,8 @@ def eye_color_code_validate_enum(cls, value): if value is None: return value - if value not in set(['BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK']): - raise ValueError("must be one of enum values ('BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK')") + if value not in set(['BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('BLK', 'BLU', 'BRO', 'DIC', 'GRY', 'GRN', 'HAZ', 'MAR', 'PNK', 'unknown_default_open_api')") return value @field_validator('gender') @@ -82,8 +82,8 @@ def gender_validate_enum(cls, value): if value is None: return value - if value not in set(['Male', 'Female']): - raise ValueError("must be one of enum values ('Male', 'Female')") + if value not in set(['Male', 'Female', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('Male', 'Female', 'unknown_default_open_api')") return value @field_validator('state') diff --git a/onfido/models/watchlist_monitor.py b/onfido/models/watchlist_monitor.py index 19f91c5..56083b0 100644 --- a/onfido/models/watchlist_monitor.py +++ b/onfido/models/watchlist_monitor.py @@ -40,8 +40,8 @@ class WatchlistMonitor(BaseModel): @field_validator('report_name') def report_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['watchlist_standard', 'watchlist_aml']): - raise ValueError("must be one of enum values ('watchlist_standard', 'watchlist_aml')") + if value not in set(['watchlist_standard', 'watchlist_aml', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('watchlist_standard', 'watchlist_aml', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/watchlist_monitor_builder.py b/onfido/models/watchlist_monitor_builder.py index 29018c0..82239f3 100644 --- a/onfido/models/watchlist_monitor_builder.py +++ b/onfido/models/watchlist_monitor_builder.py @@ -35,8 +35,8 @@ class WatchlistMonitorBuilder(BaseModel): @field_validator('report_name') def report_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['watchlist_standard', 'watchlist_aml']): - raise ValueError("must be one of enum values ('watchlist_standard', 'watchlist_aml')") + if value not in set(['watchlist_standard', 'watchlist_aml', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('watchlist_standard', 'watchlist_aml', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/watchlist_monitor_shared.py b/onfido/models/watchlist_monitor_shared.py index 1edbe1a..85095cc 100644 --- a/onfido/models/watchlist_monitor_shared.py +++ b/onfido/models/watchlist_monitor_shared.py @@ -35,8 +35,8 @@ class WatchlistMonitorShared(BaseModel): @field_validator('report_name') def report_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['watchlist_standard', 'watchlist_aml']): - raise ValueError("must be one of enum values ('watchlist_standard', 'watchlist_aml')") + if value not in set(['watchlist_standard', 'watchlist_aml', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('watchlist_standard', 'watchlist_aml', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/webhook_event_object_status.py b/onfido/models/webhook_event_object_status.py index 31f52c0..4470429 100644 --- a/onfido/models/webhook_event_object_status.py +++ b/onfido/models/webhook_event_object_status.py @@ -45,6 +45,7 @@ class WebhookEventObjectStatus(str, Enum): AWAITING_APPLICANT = 'awaiting_applicant' PAUSED = 'paused' REOPENED = 'reopened' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/webhook_event_resource_type.py b/onfido/models/webhook_event_resource_type.py index bdb97d8..bb0dd56 100644 --- a/onfido/models/webhook_event_resource_type.py +++ b/onfido/models/webhook_event_resource_type.py @@ -34,6 +34,7 @@ class WebhookEventResourceType(str, Enum): WATCHLIST_MONITOR = 'watchlist_monitor' WORKFLOW_TIMELINE_FILE = 'workflow_timeline_file' WORKFLOW_RUN_EVIDENCE_FOLDER = 'workflow_run_evidence_folder' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/webhook_event_type.py b/onfido/models/webhook_event_type.py index 131d942..b460ff2 100644 --- a/onfido/models/webhook_event_type.py +++ b/onfido/models/webhook_event_type.py @@ -43,6 +43,7 @@ class WebhookEventType(str, Enum): REPORT_DOT_COMPLETED = 'report.completed' WORKFLOW_TIMELINE_FILE_DOT_CREATED = 'workflow_timeline_file.created' WORKFLOW_RUN_EVIDENCE_FOLDER_DOT_CREATED = 'workflow_run_evidence_folder.created' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/workflow_run_link.py b/onfido/models/workflow_run_link.py index c7449a2..8c3a8a4 100644 --- a/onfido/models/workflow_run_link.py +++ b/onfido/models/workflow_run_link.py @@ -41,8 +41,8 @@ def language_validate_enum(cls, value): if value is None: return value - if value not in set(['en_US', 'de_DE', 'es_ES', 'fr_FR', 'it_IT', 'pt_PT', 'nl_NL']): - raise ValueError("must be one of enum values ('en_US', 'de_DE', 'es_ES', 'fr_FR', 'it_IT', 'pt_PT', 'nl_NL')") + if value not in set(['en_US', 'de_DE', 'es_ES', 'fr_FR', 'it_IT', 'pt_PT', 'nl_NL', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('en_US', 'de_DE', 'es_ES', 'fr_FR', 'it_IT', 'pt_PT', 'nl_NL', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/onfido/models/workflow_run_status.py b/onfido/models/workflow_run_status.py index 790ddd2..aff9149 100644 --- a/onfido/models/workflow_run_status.py +++ b/onfido/models/workflow_run_status.py @@ -34,6 +34,7 @@ class WorkflowRunStatus(str, Enum): REVIEW = 'review' ABANDONED = 'abandoned' ERROR = 'error' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/poetry.lock b/poetry.lock index a1c258a..fcfef73 100644 --- a/poetry.lock +++ b/poetry.lock @@ -693,4 +693,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "3de3538285216feccde17da5b9808bfe32e863fd34121d6836ae12eb08279c88" +content-hash = "032b9e666fa9926f756acb47507f11fc7e48192c1fb197243f24241e20b4b871" diff --git a/pyproject.toml b/pyproject.toml index 00f9199..bc8a6e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ package-mode = false [tool.poetry.dependencies] python = "^3.8" -urllib3 = ">= 1.25.3 < 3.0.0" +urllib3 = ">= 1.25.3, < 3.0.0" python-dateutil = ">= 2.8.2" pydantic = ">= 2" typing-extensions = ">= 4.7.1" @@ -53,7 +53,7 @@ warn_unused_ignores = true ## Getting these passing should be easy strict_equality = true -strict_concatenate = true +extra_checks = true ## Strongly recommend enabling this one as soon as you can check_untyped_defs = true @@ -74,3 +74,20 @@ disallow_any_generics = true # ### This one can be tricky to get passing if you use a lot of untyped libraries #warn_return_any = true + +[[tool.mypy.overrides]] +module = [ + "onfido.configuration", +] +warn_unused_ignores = true +strict_equality = true +extra_checks = true +check_untyped_defs = true +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true +disallow_untyped_calls = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +no_implicit_reexport = true +warn_return_any = true From cf158ed23921775e6d9b3b71e570bf6d48f949be Mon Sep 17 00:00:00 2001 From: Davide Vacca Date: Thu, 20 Feb 2025 12:41:41 +0100 Subject: [PATCH 2/2] Update Migration guide after major release --- .markdownlint.json | 3 +++ MIGRATION.md | 31 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .markdownlint.json diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..f2a375a --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,3 @@ +{ + "MD024": false +} diff --git a/MIGRATION.md b/MIGRATION.md index df4264d..420af30 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,5 +1,34 @@ # Migration Guide +This guide provides detailed instructions on how to upgrade between different +major versions of the client library. + +It covers changes in core resources, other endpoints, and the OpenAPI generator, +ensuring a smooth transition between versions. + +## Upgrading from 4.x to 5.x + +### Core Resources + +- Documents + - Allow any string as `file_type` + +### Other Endpoints + +- Webhooks + - Drop `WORKFLOW_SIGNED_EVIDENCE_FILE_DOT_CREATED` enum value from + `WebhookEventType` enum + - Make `href` property in `WebhookEventPayloadObject` optional +- Reports + - Allow the deprecated `records` property in `WatchlistAml` and + `WatchlistStandard` reports to be any object, and not just a string + - Remove `documents` property from all reports except Document and + Facial Similarity reports + +### OpenAPI generator + +- Version upgraded from `7.9.0` to `7.11.0` + ## Upgrading from 3.x to 4.x ### Core Resources @@ -27,5 +56,5 @@ ### OpenAPI generator -- Version upgraded from 7.6.0 to 7.9.0 +- Version upgraded from `7.6.0` to `7.9.0` - Remove support for python 3.7