From c3bcfe7a3937e4a15bbaff0727f214d2fe85b89b Mon Sep 17 00:00:00 2001 From: jmulford-bw Date: Mon, 8 Mar 2021 21:33:20 +0000 Subject: [PATCH 1/3] New deploy --- bandwidth/bandwidth_client.py | 14 +- bandwidth/configuration.py | 34 +-- bandwidth/http/auth/__init__.py | 2 +- ...uth.py => multi_factor_auth_basic_auth.py} | 6 +- .../messaging/controllers/api_controller.py | 139 +++++----- bandwidth/messaging/exceptions/__init__.py | 2 +- ...=> messaging_exception_error_exception.py} | 6 +- bandwidth/messaging/messaging_client.py | 8 +- bandwidth/messaging/models/__init__.py | 1 + bandwidth/messaging/models/media.py | 55 +--- .../messaging/models/messaging_exception.py | 60 ++++ .../__init__.py | 2 +- .../controllers/__init__.py | 0 .../controllers/base_controller.py | 0 .../controllers/mfa_controller.py | 54 ++-- .../multifactorauth/exceptions/__init__.py | 5 + .../error_with_request_error_exception.py} | 6 +- .../forbidden_request_error_exception.py} | 6 +- .../unauthorized_request_error_exception.py} | 6 +- .../models/__init__.py | 3 + .../models/error_with_request.py | 61 +++++ .../models/forbidden_request.py | 55 ++++ .../models/two_factor_code_request_schema.py | 0 .../models/two_factor_messaging_response.py | 0 .../models/two_factor_verify_code_response.py | 0 .../two_factor_verify_request_schema.py | 0 .../models/two_factor_voice_response.py | 0 .../models/unauthorized_request.py | 55 ++++ .../multi_factor_auth_client.py} | 12 +- .../twofactorauth/exceptions/__init__.py | 5 - bandwidth/voice/__init__.py | 5 +- bandwidth/voice/controllers/api_controller.py | 256 +++++++++--------- bandwidth/voice/exceptions/__init__.py | 2 +- ... => api_error_response_error_exception.py} | 6 +- bandwidth/voice/models/__init__.py | 1 + .../voice/models/api_call_state_response.py | 12 + bandwidth/voice/models/api_error_response.py | 66 +++++ bandwidth/voice/voice_client.py | 8 +- .../webrtc/controllers/api_controller.py | 24 +- bandwidth/webrtc/exceptions/__init__.py | 2 +- ..._exception.py => error_error_exception.py} | 6 +- bandwidth/webrtc/models/__init__.py | 2 + .../webrtc/models/device_api_version_enum.py | 24 ++ bandwidth/webrtc/models/error.py | 60 ++++ bandwidth/webrtc/models/participant.py | 13 +- bandwidth/webrtc/web_rtc_client.py | 8 +- requirements.txt | 1 - setup.py | 4 +- 48 files changed, 727 insertions(+), 370 deletions(-) rename bandwidth/http/auth/{two_factor_auth_basic_auth.py => multi_factor_auth_basic_auth.py} (79%) rename bandwidth/messaging/exceptions/{messaging_exception.py => messaging_exception_error_exception.py} (79%) create mode 100644 bandwidth/messaging/models/messaging_exception.py rename bandwidth/{twofactorauth => multifactorauth}/__init__.py (64%) rename bandwidth/{twofactorauth => multifactorauth}/controllers/__init__.py (100%) rename bandwidth/{twofactorauth => multifactorauth}/controllers/base_controller.py (100%) rename bandwidth/{twofactorauth => multifactorauth}/controllers/mfa_controller.py (69%) create mode 100644 bandwidth/multifactorauth/exceptions/__init__.py rename bandwidth/{twofactorauth/exceptions/error_with_request_exception.py => multifactorauth/exceptions/error_with_request_error_exception.py} (79%) rename bandwidth/{twofactorauth/exceptions/forbidden_request_exception.py => multifactorauth/exceptions/forbidden_request_error_exception.py} (79%) rename bandwidth/{twofactorauth/exceptions/unauthorized_request_exception.py => multifactorauth/exceptions/unauthorized_request_error_exception.py} (78%) rename bandwidth/{twofactorauth => multifactorauth}/models/__init__.py (69%) create mode 100644 bandwidth/multifactorauth/models/error_with_request.py create mode 100644 bandwidth/multifactorauth/models/forbidden_request.py rename bandwidth/{twofactorauth => multifactorauth}/models/two_factor_code_request_schema.py (100%) rename bandwidth/{twofactorauth => multifactorauth}/models/two_factor_messaging_response.py (100%) rename bandwidth/{twofactorauth => multifactorauth}/models/two_factor_verify_code_response.py (100%) rename bandwidth/{twofactorauth => multifactorauth}/models/two_factor_verify_request_schema.py (100%) rename bandwidth/{twofactorauth => multifactorauth}/models/two_factor_voice_response.py (100%) create mode 100644 bandwidth/multifactorauth/models/unauthorized_request.py rename bandwidth/{twofactorauth/two_factor_auth_client.py => multifactorauth/multi_factor_auth_client.py} (77%) delete mode 100644 bandwidth/twofactorauth/exceptions/__init__.py rename bandwidth/voice/exceptions/{api_error_response_exception.py => api_error_response_error_exception.py} (80%) create mode 100644 bandwidth/voice/models/api_error_response.py rename bandwidth/webrtc/exceptions/{error_exception.py => error_error_exception.py} (81%) create mode 100644 bandwidth/webrtc/models/device_api_version_enum.py create mode 100644 bandwidth/webrtc/models/error.py diff --git a/bandwidth/bandwidth_client.py b/bandwidth/bandwidth_client.py index ab40fdca..85b41674 100644 --- a/bandwidth/bandwidth_client.py +++ b/bandwidth/bandwidth_client.py @@ -10,7 +10,7 @@ from bandwidth.configuration import Configuration from bandwidth.configuration import Environment from bandwidth.messaging.messaging_client import MessagingClient -from bandwidth.twofactorauth.two_factor_auth_client import TwoFactorAuthClient +from bandwidth.multifactorauth.multi_factor_auth_client import MultiFactorAuthClient from bandwidth.voice.voice_client import VoiceClient from bandwidth.webrtc.web_rtc_client import WebRtcClient @@ -22,8 +22,8 @@ def messaging_client(self): return MessagingClient(config=self.config) @lazy_property - def two_factor_auth_client(self): - return TwoFactorAuthClient(config=self.config) + def multi_factor_auth_client(self): + return MultiFactorAuthClient(config=self.config) @lazy_property def voice_client(self): @@ -38,8 +38,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - two_factor_auth_basic_auth_user_name='TODO: Replace', - two_factor_auth_basic_auth_password='TODO: Replace', + multi_factor_auth_basic_auth_user_name='TODO: Replace', + multi_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -52,8 +52,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, - two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, + multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, + multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/configuration.py b/bandwidth/configuration.py index a5071857..7c9fd61b 100644 --- a/bandwidth/configuration.py +++ b/bandwidth/configuration.py @@ -21,7 +21,7 @@ class Server(Enum): """An enum for API servers""" DEFAULT = 0 MESSAGINGDEFAULT = 1 - TWOFACTORAUTHDEFAULT = 2 + MULTIFACTORAUTHDEFAULT = 2 VOICEDEFAULT = 3 WEBRTCDEFAULT = 4 @@ -63,12 +63,12 @@ def messaging_basic_auth_password(self): return self._messaging_basic_auth_password @property - def two_factor_auth_basic_auth_user_name(self): - return self._two_factor_auth_basic_auth_user_name + def multi_factor_auth_basic_auth_user_name(self): + return self._multi_factor_auth_basic_auth_user_name @property - def two_factor_auth_basic_auth_password(self): - return self._two_factor_auth_basic_auth_password + def multi_factor_auth_basic_auth_password(self): + return self._multi_factor_auth_basic_auth_password @property def voice_basic_auth_user_name(self): @@ -91,8 +91,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - two_factor_auth_basic_auth_user_name='TODO: Replace', - two_factor_auth_basic_auth_password='TODO: Replace', + multi_factor_auth_basic_auth_user_name='TODO: Replace', + multi_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -121,10 +121,10 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, self._messaging_basic_auth_password = messaging_basic_auth_password # The username to use with basic authentication - self._two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name + self._multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name # The password to use with basic authentication - self._two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password + self._multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password # The username to use with basic authentication self._voice_basic_auth_user_name = voice_basic_auth_user_name @@ -145,8 +145,8 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None, environment=None, base_url=None, messaging_basic_auth_user_name=None, messaging_basic_auth_password=None, - two_factor_auth_basic_auth_user_name=None, - two_factor_auth_basic_auth_password=None, + multi_factor_auth_basic_auth_user_name=None, + multi_factor_auth_basic_auth_password=None, voice_basic_auth_user_name=None, voice_basic_auth_password=None, web_rtc_basic_auth_user_name=None, @@ -158,8 +158,8 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None, base_url = base_url or self.base_url messaging_basic_auth_user_name = messaging_basic_auth_user_name or self.messaging_basic_auth_user_name messaging_basic_auth_password = messaging_basic_auth_password or self.messaging_basic_auth_password - two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name or self.two_factor_auth_basic_auth_user_name - two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password or self.two_factor_auth_basic_auth_password + multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name or self.multi_factor_auth_basic_auth_user_name + multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password or self.multi_factor_auth_basic_auth_password voice_basic_auth_user_name = voice_basic_auth_user_name or self.voice_basic_auth_user_name voice_basic_auth_password = voice_basic_auth_password or self.voice_basic_auth_password web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name or self.web_rtc_basic_auth_user_name @@ -170,8 +170,8 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None, backoff_factor=backoff_factor, environment=environment, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, - two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, + multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, + multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, @@ -188,14 +188,14 @@ def create_http_client(self): Environment.PRODUCTION: { Server.DEFAULT: 'api.bandwidth.com', Server.MESSAGINGDEFAULT: 'https://messaging.bandwidth.com/api/v2', - Server.TWOFACTORAUTHDEFAULT: 'https://mfa.bandwidth.com/api/v1', + Server.MULTIFACTORAUTHDEFAULT: 'https://mfa.bandwidth.com/api/v1', Server.VOICEDEFAULT: 'https://voice.bandwidth.com', Server.WEBRTCDEFAULT: 'https://api.webrtc.bandwidth.com/v1' }, Environment.CUSTOM: { Server.DEFAULT: '{base_url}', Server.MESSAGINGDEFAULT: '{base_url}', - Server.TWOFACTORAUTHDEFAULT: '{base_url}', + Server.MULTIFACTORAUTHDEFAULT: '{base_url}', Server.VOICEDEFAULT: '{base_url}', Server.WEBRTCDEFAULT: '{base_url}' } diff --git a/bandwidth/http/auth/__init__.py b/bandwidth/http/auth/__init__.py index 8ce8edd6..666a8cd4 100644 --- a/bandwidth/http/auth/__init__.py +++ b/bandwidth/http/auth/__init__.py @@ -1,6 +1,6 @@ __all__ = [ 'messaging_basic_auth', - 'two_factor_auth_basic_auth', + 'multi_factor_auth_basic_auth', 'voice_basic_auth', 'web_rtc_basic_auth', ] diff --git a/bandwidth/http/auth/two_factor_auth_basic_auth.py b/bandwidth/http/auth/multi_factor_auth_basic_auth.py similarity index 79% rename from bandwidth/http/auth/two_factor_auth_basic_auth.py rename to bandwidth/http/auth/multi_factor_auth_basic_auth.py index c370f3ff..e1225e12 100644 --- a/bandwidth/http/auth/two_factor_auth_basic_auth.py +++ b/bandwidth/http/auth/multi_factor_auth_basic_auth.py @@ -9,7 +9,7 @@ import base64 -class TwoFactorAuthBasicAuth: +class MultiFactorAuthBasicAuth: @staticmethod def apply(config, http_request): @@ -22,8 +22,8 @@ def apply(config, http_request): authentication will be added. """ - username = config.two_factor_auth_basic_auth_user_name - password = config.two_factor_auth_basic_auth_password + username = config.multi_factor_auth_basic_auth_user_name + password = config.multi_factor_auth_basic_auth_password joined = "{}:{}".format(username, password) encoded = base64.b64encode(str.encode(joined)).decode('iso-8859-1') header_value = "Basic {}".format(encoded) diff --git a/bandwidth/messaging/controllers/api_controller.py b/bandwidth/messaging/controllers/api_controller.py index cfd9ef04..5ab67aea 100644 --- a/bandwidth/messaging/controllers/api_controller.py +++ b/bandwidth/messaging/controllers/api_controller.py @@ -15,7 +15,7 @@ from bandwidth.messaging.models.media import Media from bandwidth.messaging.models.bandwidth_messages_list import BandwidthMessagesList from bandwidth.messaging.models.bandwidth_message import BandwidthMessage -from bandwidth.messaging.exceptions.messaging_exception import MessagingException +from bandwidth.messaging.exceptions.messaging_exception_error_exception import MessagingExceptionErrorException class APIController(BaseController): @@ -26,14 +26,14 @@ def __init__(self, config, call_back=None): super(APIController, self).__init__(config, call_back) def list_media(self, - user_id, + account_id, continuation_token=None): - """Does a GET request to /users/{userId}/media. + """Does a GET request to /users/{accountId}/media. listMedia Args: - user_id (string): User's account ID + account_id (string): User's account ID continuation_token (string, optional): Continuation token used to retrieve subsequent media. @@ -51,9 +51,9 @@ def list_media(self, """ # Prepare query URL - _url_path = '/users/{userId}/media' + _url_path = '/users/{accountId}/media' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'userId': {'value': user_id, 'encode': False} + 'accountId': {'value': account_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) _query_builder += _url_path @@ -72,17 +72,17 @@ def list_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingException('400 Request is malformed or invalid', _response) + raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingException('401 The specified user does not have access to the account', _response) + raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingException('403 The user does not have access to this API', _response) + raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingException('404 Path not found', _response) + raise MessagingExceptionErrorException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingException('415 The content-type of the request is incorrect', _response) + raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingException('429 The rate limit has been reached', _response) + raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Media.from_dictionary) @@ -90,14 +90,14 @@ def list_media(self, return _result def get_media(self, - user_id, + account_id, media_id): - """Does a GET request to /users/{userId}/media/{mediaId}. + """Does a GET request to /users/{accountId}/media/{mediaId}. getMedia Args: - user_id (string): User's account ID + account_id (string): User's account ID media_id (string): Media ID to retrieve Returns: @@ -114,9 +114,9 @@ def get_media(self, """ # Prepare query URL - _url_path = '/users/{userId}/media/{mediaId}' + _url_path = '/users/{accountId}/media/{mediaId}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'userId': {'value': user_id, 'encode': False}, + 'accountId': {'value': account_id, 'encode': False}, 'mediaId': {'value': media_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) @@ -130,17 +130,17 @@ def get_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingException('400 Request is malformed or invalid', _response) + raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingException('401 The specified user does not have access to the account', _response) + raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingException('403 The user does not have access to this API', _response) + raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingException('404 Path not found', _response) + raise MessagingExceptionErrorException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingException('415 The content-type of the request is incorrect', _response) + raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingException('429 The rate limit has been reached', _response) + raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = _response.text @@ -148,20 +148,18 @@ def get_media(self, return _result def upload_media(self, - user_id, + account_id, media_id, - content_length, body, content_type='application/octet-stream', cache_control=None): - """Does a PUT request to /users/{userId}/media/{mediaId}. + """Does a PUT request to /users/{accountId}/media/{mediaId}. uploadMedia Args: - user_id (string): User's account ID + account_id (string): User's account ID media_id (string): The user supplied custom media ID - content_length (long|int): The size of the entity-body body (typing.BinaryIO): TODO: type description here. content_type (string, optional): The media type of the entity-body @@ -182,9 +180,9 @@ def upload_media(self, """ # Prepare query URL - _url_path = '/users/{userId}/media/{mediaId}' + _url_path = '/users/{accountId}/media/{mediaId}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'userId': {'value': user_id, 'encode': False}, + 'accountId': {'value': account_id, 'encode': False}, 'mediaId': {'value': media_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) @@ -201,7 +199,6 @@ def upload_media(self, # Prepare headers _headers = { 'content-type': body_content_type, - 'Content-Length': content_length, 'Cache-Control': cache_control } @@ -212,31 +209,31 @@ def upload_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingException('400 Request is malformed or invalid', _response) + raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingException('401 The specified user does not have access to the account', _response) + raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingException('403 The user does not have access to this API', _response) + raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingException('404 Path not found', _response) + raise MessagingExceptionErrorException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingException('415 The content-type of the request is incorrect', _response) + raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingException('429 The rate limit has been reached', _response) + raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) self.validate_response(_response) # Return appropriate type return ApiResponse(_response) def delete_media(self, - user_id, + account_id, media_id): - """Does a DELETE request to /users/{userId}/media/{mediaId}. + """Does a DELETE request to /users/{accountId}/media/{mediaId}. deleteMedia Args: - user_id (string): User's account ID + account_id (string): User's account ID media_id (string): The media ID to delete Returns: @@ -252,9 +249,9 @@ def delete_media(self, """ # Prepare query URL - _url_path = '/users/{userId}/media/{mediaId}' + _url_path = '/users/{accountId}/media/{mediaId}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'userId': {'value': user_id, 'encode': False}, + 'accountId': {'value': account_id, 'encode': False}, 'mediaId': {'value': media_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) @@ -268,24 +265,24 @@ def delete_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingException('400 Request is malformed or invalid', _response) + raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingException('401 The specified user does not have access to the account', _response) + raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingException('403 The user does not have access to this API', _response) + raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingException('404 Path not found', _response) + raise MessagingExceptionErrorException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingException('415 The content-type of the request is incorrect', _response) + raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingException('429 The rate limit has been reached', _response) + raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) self.validate_response(_response) # Return appropriate type return ApiResponse(_response) def get_messages(self, - user_id, + account_id, message_id=None, source_tn=None, destination_tn=None, @@ -295,12 +292,12 @@ def get_messages(self, to_date_time=None, page_token=None, limit=None): - """Does a GET request to /users/{userId}/messages. + """Does a GET request to /users/{accountId}/messages. getMessages Args: - user_id (string): User's account ID + account_id (string): User's account ID message_id (string, optional): The ID of the message to search for. Special characters need to be encoded using URL encoding source_tn (string, optional): The phone number that sent the @@ -309,7 +306,7 @@ def get_messages(self, the message message_status (string, optional): The status of the message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, - DLR_EXPIRED + ACCEPTED, UNDELIVERED error_code (int, optional): The error code of the message from_date_time (string, optional): The start of the date range to search in ISO 8601 format. Uses the message receive time. The @@ -337,9 +334,9 @@ def get_messages(self, """ # Prepare query URL - _url_path = '/users/{userId}/messages' + _url_path = '/users/{accountId}/messages' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'userId': {'value': user_id, 'encode': False} + 'accountId': {'value': account_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) _query_builder += _url_path @@ -372,17 +369,17 @@ def get_messages(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingException('400 Request is malformed or invalid', _response) + raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingException('401 The specified user does not have access to the account', _response) + raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingException('403 The user does not have access to this API', _response) + raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingException('404 Path not found', _response) + raise MessagingExceptionErrorException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingException('415 The content-type of the request is incorrect', _response) + raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingException('429 The rate limit has been reached', _response) + raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, BandwidthMessagesList.from_dictionary) @@ -390,14 +387,14 @@ def get_messages(self, return _result def create_message(self, - user_id, + account_id, body): - """Does a POST request to /users/{userId}/messages. + """Does a POST request to /users/{accountId}/messages. createMessage Args: - user_id (string): User's account ID + account_id (string): User's account ID body (MessageRequest): TODO: type description here. Returns: @@ -414,9 +411,9 @@ def create_message(self, """ # Prepare query URL - _url_path = '/users/{userId}/messages' + _url_path = '/users/{accountId}/messages' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'userId': {'value': user_id, 'encode': False} + 'accountId': {'value': account_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) _query_builder += _url_path @@ -435,17 +432,17 @@ def create_message(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingException('400 Request is malformed or invalid', _response) + raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingException('401 The specified user does not have access to the account', _response) + raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingException('403 The user does not have access to this API', _response) + raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingException('404 Path not found', _response) + raise MessagingExceptionErrorException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingException('415 The content-type of the request is incorrect', _response) + raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingException('429 The rate limit has been reached', _response) + raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, BandwidthMessage.from_dictionary) diff --git a/bandwidth/messaging/exceptions/__init__.py b/bandwidth/messaging/exceptions/__init__.py index 8d2920ac..b135f5bb 100644 --- a/bandwidth/messaging/exceptions/__init__.py +++ b/bandwidth/messaging/exceptions/__init__.py @@ -1,3 +1,3 @@ __all__ = [ - 'messaging_exception', + 'messaging_exception_error_exception', ] diff --git a/bandwidth/messaging/exceptions/messaging_exception.py b/bandwidth/messaging/exceptions/messaging_exception_error_exception.py similarity index 79% rename from bandwidth/messaging/exceptions/messaging_exception.py rename to bandwidth/messaging/exceptions/messaging_exception_error_exception.py index 283ebde2..90f5e28a 100644 --- a/bandwidth/messaging/exceptions/messaging_exception.py +++ b/bandwidth/messaging/exceptions/messaging_exception_error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class MessagingException(bandwidth.exceptions.api_exception.APIException): +class MessagingExceptionErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the MessagingException class + """Constructor for the MessagingExceptionErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(MessagingException, self).__init__(reason, response) + super(MessagingExceptionErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/messaging/messaging_client.py b/bandwidth/messaging/messaging_client.py index 86b29def..664b8acc 100644 --- a/bandwidth/messaging/messaging_client.py +++ b/bandwidth/messaging/messaging_client.py @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - two_factor_auth_basic_auth_user_name='TODO: Replace', - two_factor_auth_basic_auth_password='TODO: Replace', + multi_factor_auth_basic_auth_user_name='TODO: Replace', + multi_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, - two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, + multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, + multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/messaging/models/__init__.py b/bandwidth/messaging/models/__init__.py index ef3a90d5..750078eb 100644 --- a/bandwidth/messaging/models/__init__.py +++ b/bandwidth/messaging/models/__init__.py @@ -2,6 +2,7 @@ 'bandwidth_messages_list', 'bandwidth_message_item', 'page_info', + 'messaging_exception', 'media', 'tag', 'deferred_result', diff --git a/bandwidth/messaging/models/media.py b/bandwidth/messaging/models/media.py index 8309228e..1fb9c53e 100644 --- a/bandwidth/messaging/models/media.py +++ b/bandwidth/messaging/models/media.py @@ -5,7 +5,6 @@ This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). """ -from bandwidth.messaging.models.tag import Tag class Media(object): @@ -15,57 +14,29 @@ class Media(object): TODO: type model description here. Attributes: - input_stream (object): TODO: type description here. content (string): TODO: type description here. - url (string): TODO: type description here. - content_length (string): TODO: type description here. - content_type (string): TODO: type description here. - tags (list of Tag): TODO: type description here. - user_id (string): User's account ID + content_length (int): TODO: type description here. media_name (string): TODO: type description here. - media_id (string): TODO: type description here. - cache_control (string): TODO: type description here. """ # Create a mapping from Model property names to API property names _names = { - "input_stream": 'inputStream', "content": 'content', - "url": 'url', "content_length": 'contentLength', - "content_type": 'contentType', - "tags": 'tags', - "user_id": 'userId', - "media_name": 'mediaName', - "media_id": 'mediaId', - "cache_control": 'cacheControl' + "media_name": 'mediaName' } def __init__(self, - input_stream=None, content=None, - url=None, content_length=None, - content_type=None, - tags=None, - user_id=None, - media_name=None, - media_id=None, - cache_control=None): + media_name=None): """Constructor for the Media class""" # Initialize members of the class - self.input_stream = input_stream self.content = content - self.url = url self.content_length = content_length - self.content_type = content_type - self.tags = tags - self.user_id = user_id self.media_name = media_name - self.media_id = media_id - self.cache_control = cache_control @classmethod def from_dictionary(cls, @@ -85,27 +56,11 @@ def from_dictionary(cls, return None # Extract variables from the dictionary - input_stream = dictionary.get('inputStream') content = dictionary.get('content') - url = dictionary.get('url') content_length = dictionary.get('contentLength') - content_type = dictionary.get('contentType') - tags = None - if dictionary.get('tags') is not None: - tags = [Tag.from_dictionary(x) for x in dictionary.get('tags')] - user_id = dictionary.get('userId') media_name = dictionary.get('mediaName') - media_id = dictionary.get('mediaId') - cache_control = dictionary.get('cacheControl') # Return an object of this model - return cls(input_stream, - content, - url, + return cls(content, content_length, - content_type, - tags, - user_id, - media_name, - media_id, - cache_control) + media_name) diff --git a/bandwidth/messaging/models/messaging_exception.py b/bandwidth/messaging/models/messaging_exception.py new file mode 100644 index 00000000..ac899a87 --- /dev/null +++ b/bandwidth/messaging/models/messaging_exception.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class MessagingException(object): + + """Implementation of the 'MessagingException' model. + + TODO: type model description here. + + Attributes: + mtype (string): TODO: type description here. + description (string): TODO: type description here. + + """ + + # Create a mapping from Model property names to API property names + _names = { + "mtype": 'type', + "description": 'description' + } + + def __init__(self, + mtype=None, + description=None): + """Constructor for the MessagingException class""" + + # Initialize members of the class + self.mtype = mtype + self.description = description + + @classmethod + def from_dictionary(cls, + dictionary): + """Creates an instance of this model from a dictionary + + Args: + dictionary (dictionary): A dictionary representation of the object + as obtained from the deserialization of the server's response. The + keys MUST match property names in the API description. + + Returns: + object: An instance of this structure class. + + """ + if dictionary is None: + return None + + # Extract variables from the dictionary + mtype = dictionary.get('type') + description = dictionary.get('description') + + # Return an object of this model + return cls(mtype, + description) diff --git a/bandwidth/twofactorauth/__init__.py b/bandwidth/multifactorauth/__init__.py similarity index 64% rename from bandwidth/twofactorauth/__init__.py rename to bandwidth/multifactorauth/__init__.py index dbf8f2d9..ba8fd824 100644 --- a/bandwidth/twofactorauth/__init__.py +++ b/bandwidth/multifactorauth/__init__.py @@ -2,5 +2,5 @@ 'controllers', 'exceptions', 'models', - 'two_factor_auth_client', + 'multi_factor_auth_client', ] diff --git a/bandwidth/twofactorauth/controllers/__init__.py b/bandwidth/multifactorauth/controllers/__init__.py similarity index 100% rename from bandwidth/twofactorauth/controllers/__init__.py rename to bandwidth/multifactorauth/controllers/__init__.py diff --git a/bandwidth/twofactorauth/controllers/base_controller.py b/bandwidth/multifactorauth/controllers/base_controller.py similarity index 100% rename from bandwidth/twofactorauth/controllers/base_controller.py rename to bandwidth/multifactorauth/controllers/base_controller.py diff --git a/bandwidth/twofactorauth/controllers/mfa_controller.py b/bandwidth/multifactorauth/controllers/mfa_controller.py similarity index 69% rename from bandwidth/twofactorauth/controllers/mfa_controller.py rename to bandwidth/multifactorauth/controllers/mfa_controller.py index 648ab148..453d66c5 100644 --- a/bandwidth/twofactorauth/controllers/mfa_controller.py +++ b/bandwidth/multifactorauth/controllers/mfa_controller.py @@ -9,14 +9,14 @@ from bandwidth.api_helper import APIHelper from bandwidth.configuration import Server from bandwidth.http.api_response import ApiResponse -from bandwidth.twofactorauth.controllers.base_controller import BaseController -from bandwidth.http.auth.two_factor_auth_basic_auth import TwoFactorAuthBasicAuth -from bandwidth.twofactorauth.models.two_factor_voice_response import TwoFactorVoiceResponse -from bandwidth.twofactorauth.models.two_factor_messaging_response import TwoFactorMessagingResponse -from bandwidth.twofactorauth.models.two_factor_verify_code_response import TwoFactorVerifyCodeResponse -from bandwidth.twofactorauth.exceptions.error_with_request_exception import ErrorWithRequestException -from bandwidth.twofactorauth.exceptions.unauthorized_request_exception import UnauthorizedRequestException -from bandwidth.twofactorauth.exceptions.forbidden_request_exception import ForbiddenRequestException +from bandwidth.multifactorauth.controllers.base_controller import BaseController +from bandwidth.http.auth.multi_factor_auth_basic_auth import MultiFactorAuthBasicAuth +from bandwidth.multifactorauth.models.two_factor_voice_response import TwoFactorVoiceResponse +from bandwidth.multifactorauth.models.two_factor_messaging_response import TwoFactorMessagingResponse +from bandwidth.multifactorauth.models.two_factor_verify_code_response import TwoFactorVerifyCodeResponse +from bandwidth.multifactorauth.exceptions.error_with_request_error_exception import ErrorWithRequestErrorException +from bandwidth.multifactorauth.exceptions.unauthorized_request_error_exception import UnauthorizedRequestErrorException +from bandwidth.multifactorauth.exceptions.forbidden_request_error_exception import ForbiddenRequestErrorException class MFAController(BaseController): @@ -56,7 +56,7 @@ def create_voice_two_factor(self, _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'accountId': {'value': account_id, 'encode': False} }) - _query_builder = self.config.get_base_uri(Server.TWOFACTORAUTHDEFAULT) + _query_builder = self.config.get_base_uri(Server.MULTIFACTORAUTHDEFAULT) _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) @@ -68,18 +68,18 @@ def create_voice_two_factor(self, # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) - TwoFactorAuthBasicAuth.apply(self.config, _request) + MultiFactorAuthBasicAuth.apply(self.config, _request) _response = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ErrorWithRequestException('If there is any issue with values passed in by the user', _response) + raise ErrorWithRequestErrorException('If there is any issue with values passed in by the user', _response) elif _response.status_code == 401: - raise UnauthorizedRequestException('Authentication is either incorrect or not present', _response) + raise UnauthorizedRequestErrorException('Authentication is either incorrect or not present', _response) elif _response.status_code == 403: - raise ForbiddenRequestException('The user is not authorized to access this resource', _response) + raise ForbiddenRequestErrorException('The user is not authorized to access this resource', _response) elif _response.status_code == 500: - raise ErrorWithRequestException('An internal server error occurred', _response) + raise ErrorWithRequestErrorException('An internal server error occurred', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TwoFactorVoiceResponse.from_dictionary) @@ -116,7 +116,7 @@ def create_messaging_two_factor(self, _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'accountId': {'value': account_id, 'encode': False} }) - _query_builder = self.config.get_base_uri(Server.TWOFACTORAUTHDEFAULT) + _query_builder = self.config.get_base_uri(Server.MULTIFACTORAUTHDEFAULT) _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) @@ -128,18 +128,18 @@ def create_messaging_two_factor(self, # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) - TwoFactorAuthBasicAuth.apply(self.config, _request) + MultiFactorAuthBasicAuth.apply(self.config, _request) _response = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ErrorWithRequestException('If there is any issue with values passed in by the user', _response) + raise ErrorWithRequestErrorException('If there is any issue with values passed in by the user', _response) elif _response.status_code == 401: - raise UnauthorizedRequestException('Authentication is either incorrect or not present', _response) + raise UnauthorizedRequestErrorException('Authentication is either incorrect or not present', _response) elif _response.status_code == 403: - raise ForbiddenRequestException('The user is not authorized to access this resource', _response) + raise ForbiddenRequestErrorException('The user is not authorized to access this resource', _response) elif _response.status_code == 500: - raise ErrorWithRequestException('An internal server error occurred', _response) + raise ErrorWithRequestErrorException('An internal server error occurred', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TwoFactorMessagingResponse.from_dictionary) @@ -175,7 +175,7 @@ def create_verify_two_factor(self, _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'accountId': {'value': account_id, 'encode': False} }) - _query_builder = self.config.get_base_uri(Server.TWOFACTORAUTHDEFAULT) + _query_builder = self.config.get_base_uri(Server.MULTIFACTORAUTHDEFAULT) _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) @@ -187,20 +187,20 @@ def create_verify_two_factor(self, # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) - TwoFactorAuthBasicAuth.apply(self.config, _request) + MultiFactorAuthBasicAuth.apply(self.config, _request) _response = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ErrorWithRequestException('If there is any issue with values passed in by the user', _response) + raise ErrorWithRequestErrorException('If there is any issue with values passed in by the user', _response) elif _response.status_code == 401: - raise UnauthorizedRequestException('Authentication is either incorrect or not present', _response) + raise UnauthorizedRequestErrorException('Authentication is either incorrect or not present', _response) elif _response.status_code == 403: - raise ForbiddenRequestException('The user is not authorized to access this resource', _response) + raise ForbiddenRequestErrorException('The user is not authorized to access this resource', _response) elif _response.status_code == 429: - raise ErrorWithRequestException('The user has made too many bad requests and is temporarily locked out', _response) + raise ErrorWithRequestErrorException('The user has made too many bad requests and is temporarily locked out', _response) elif _response.status_code == 500: - raise ErrorWithRequestException('An internal server error occurred', _response) + raise ErrorWithRequestErrorException('An internal server error occurred', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TwoFactorVerifyCodeResponse.from_dictionary) diff --git a/bandwidth/multifactorauth/exceptions/__init__.py b/bandwidth/multifactorauth/exceptions/__init__.py new file mode 100644 index 00000000..dad74063 --- /dev/null +++ b/bandwidth/multifactorauth/exceptions/__init__.py @@ -0,0 +1,5 @@ +__all__ = [ + 'error_with_request_error_exception', + 'forbidden_request_error_exception', + 'unauthorized_request_error_exception', +] diff --git a/bandwidth/twofactorauth/exceptions/error_with_request_exception.py b/bandwidth/multifactorauth/exceptions/error_with_request_error_exception.py similarity index 79% rename from bandwidth/twofactorauth/exceptions/error_with_request_exception.py rename to bandwidth/multifactorauth/exceptions/error_with_request_error_exception.py index 3b606065..09c3eb66 100644 --- a/bandwidth/twofactorauth/exceptions/error_with_request_exception.py +++ b/bandwidth/multifactorauth/exceptions/error_with_request_error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ErrorWithRequestException(bandwidth.exceptions.api_exception.APIException): +class ErrorWithRequestErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ErrorWithRequestException class + """Constructor for the ErrorWithRequestErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ErrorWithRequestException, self).__init__(reason, response) + super(ErrorWithRequestErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/twofactorauth/exceptions/forbidden_request_exception.py b/bandwidth/multifactorauth/exceptions/forbidden_request_error_exception.py similarity index 79% rename from bandwidth/twofactorauth/exceptions/forbidden_request_exception.py rename to bandwidth/multifactorauth/exceptions/forbidden_request_error_exception.py index 41e5f82e..7b4502ae 100644 --- a/bandwidth/twofactorauth/exceptions/forbidden_request_exception.py +++ b/bandwidth/multifactorauth/exceptions/forbidden_request_error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ForbiddenRequestException(bandwidth.exceptions.api_exception.APIException): +class ForbiddenRequestErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ForbiddenRequestException class + """Constructor for the ForbiddenRequestErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ForbiddenRequestException, self).__init__(reason, response) + super(ForbiddenRequestErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/twofactorauth/exceptions/unauthorized_request_exception.py b/bandwidth/multifactorauth/exceptions/unauthorized_request_error_exception.py similarity index 78% rename from bandwidth/twofactorauth/exceptions/unauthorized_request_exception.py rename to bandwidth/multifactorauth/exceptions/unauthorized_request_error_exception.py index d9d8cd11..de3e6d0b 100644 --- a/bandwidth/twofactorauth/exceptions/unauthorized_request_exception.py +++ b/bandwidth/multifactorauth/exceptions/unauthorized_request_error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class UnauthorizedRequestException(bandwidth.exceptions.api_exception.APIException): +class UnauthorizedRequestErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the UnauthorizedRequestException class + """Constructor for the UnauthorizedRequestErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(UnauthorizedRequestException, self).__init__(reason, response) + super(UnauthorizedRequestErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/twofactorauth/models/__init__.py b/bandwidth/multifactorauth/models/__init__.py similarity index 69% rename from bandwidth/twofactorauth/models/__init__.py rename to bandwidth/multifactorauth/models/__init__.py index a22a5a11..c79f9f19 100644 --- a/bandwidth/twofactorauth/models/__init__.py +++ b/bandwidth/multifactorauth/models/__init__.py @@ -1,5 +1,8 @@ __all__ = [ 'two_factor_code_request_schema', + 'error_with_request', + 'unauthorized_request', + 'forbidden_request', 'two_factor_voice_response', 'two_factor_messaging_response', 'two_factor_verify_request_schema', diff --git a/bandwidth/multifactorauth/models/error_with_request.py b/bandwidth/multifactorauth/models/error_with_request.py new file mode 100644 index 00000000..66abc8c6 --- /dev/null +++ b/bandwidth/multifactorauth/models/error_with_request.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class ErrorWithRequest(object): + + """Implementation of the 'ErrorWithRequest' model. + + TODO: type model description here. + + Attributes: + error (string): An error message pertaining to what the issue could + be + request_id (string): The associated requestId from AWS + + """ + + # Create a mapping from Model property names to API property names + _names = { + "error": 'error', + "request_id": 'requestId' + } + + def __init__(self, + error=None, + request_id=None): + """Constructor for the ErrorWithRequest class""" + + # Initialize members of the class + self.error = error + self.request_id = request_id + + @classmethod + def from_dictionary(cls, + dictionary): + """Creates an instance of this model from a dictionary + + Args: + dictionary (dictionary): A dictionary representation of the object + as obtained from the deserialization of the server's response. The + keys MUST match property names in the API description. + + Returns: + object: An instance of this structure class. + + """ + if dictionary is None: + return None + + # Extract variables from the dictionary + error = dictionary.get('error') + request_id = dictionary.get('requestId') + + # Return an object of this model + return cls(error, + request_id) diff --git a/bandwidth/multifactorauth/models/forbidden_request.py b/bandwidth/multifactorauth/models/forbidden_request.py new file mode 100644 index 00000000..3200574f --- /dev/null +++ b/bandwidth/multifactorauth/models/forbidden_request.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class ForbiddenRequest(object): + + """Implementation of the 'ForbiddenRequest' model. + + TODO: type model description here. + + Attributes: + message (string): The message containing the reason behind the request + being forbidden + + """ + + # Create a mapping from Model property names to API property names + _names = { + "message": 'Message' + } + + def __init__(self, + message=None): + """Constructor for the ForbiddenRequest class""" + + # Initialize members of the class + self.message = message + + @classmethod + def from_dictionary(cls, + dictionary): + """Creates an instance of this model from a dictionary + + Args: + dictionary (dictionary): A dictionary representation of the object + as obtained from the deserialization of the server's response. The + keys MUST match property names in the API description. + + Returns: + object: An instance of this structure class. + + """ + if dictionary is None: + return None + + # Extract variables from the dictionary + message = dictionary.get('Message') + + # Return an object of this model + return cls(message) diff --git a/bandwidth/twofactorauth/models/two_factor_code_request_schema.py b/bandwidth/multifactorauth/models/two_factor_code_request_schema.py similarity index 100% rename from bandwidth/twofactorauth/models/two_factor_code_request_schema.py rename to bandwidth/multifactorauth/models/two_factor_code_request_schema.py diff --git a/bandwidth/twofactorauth/models/two_factor_messaging_response.py b/bandwidth/multifactorauth/models/two_factor_messaging_response.py similarity index 100% rename from bandwidth/twofactorauth/models/two_factor_messaging_response.py rename to bandwidth/multifactorauth/models/two_factor_messaging_response.py diff --git a/bandwidth/twofactorauth/models/two_factor_verify_code_response.py b/bandwidth/multifactorauth/models/two_factor_verify_code_response.py similarity index 100% rename from bandwidth/twofactorauth/models/two_factor_verify_code_response.py rename to bandwidth/multifactorauth/models/two_factor_verify_code_response.py diff --git a/bandwidth/twofactorauth/models/two_factor_verify_request_schema.py b/bandwidth/multifactorauth/models/two_factor_verify_request_schema.py similarity index 100% rename from bandwidth/twofactorauth/models/two_factor_verify_request_schema.py rename to bandwidth/multifactorauth/models/two_factor_verify_request_schema.py diff --git a/bandwidth/twofactorauth/models/two_factor_voice_response.py b/bandwidth/multifactorauth/models/two_factor_voice_response.py similarity index 100% rename from bandwidth/twofactorauth/models/two_factor_voice_response.py rename to bandwidth/multifactorauth/models/two_factor_voice_response.py diff --git a/bandwidth/multifactorauth/models/unauthorized_request.py b/bandwidth/multifactorauth/models/unauthorized_request.py new file mode 100644 index 00000000..8e896681 --- /dev/null +++ b/bandwidth/multifactorauth/models/unauthorized_request.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class UnauthorizedRequest(object): + + """Implementation of the 'UnauthorizedRequest' model. + + TODO: type model description here. + + Attributes: + message (string): The message containing the reason behind the request + being unauthorized + + """ + + # Create a mapping from Model property names to API property names + _names = { + "message": 'message' + } + + def __init__(self, + message=None): + """Constructor for the UnauthorizedRequest class""" + + # Initialize members of the class + self.message = message + + @classmethod + def from_dictionary(cls, + dictionary): + """Creates an instance of this model from a dictionary + + Args: + dictionary (dictionary): A dictionary representation of the object + as obtained from the deserialization of the server's response. The + keys MUST match property names in the API description. + + Returns: + object: An instance of this structure class. + + """ + if dictionary is None: + return None + + # Extract variables from the dictionary + message = dictionary.get('message') + + # Return an object of this model + return cls(message) diff --git a/bandwidth/twofactorauth/two_factor_auth_client.py b/bandwidth/multifactorauth/multi_factor_auth_client.py similarity index 77% rename from bandwidth/twofactorauth/two_factor_auth_client.py rename to bandwidth/multifactorauth/multi_factor_auth_client.py index f8503d84..0df23525 100644 --- a/bandwidth/twofactorauth/two_factor_auth_client.py +++ b/bandwidth/multifactorauth/multi_factor_auth_client.py @@ -9,10 +9,10 @@ from bandwidth.decorators import lazy_property from bandwidth.configuration import Configuration from bandwidth.configuration import Environment -from bandwidth.twofactorauth.controllers.mfa_controller import MFAController +from bandwidth.multifactorauth.controllers.mfa_controller import MFAController -class TwoFactorAuthClient(object): +class MultiFactorAuthClient(object): @lazy_property def mfa(self): @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - two_factor_auth_basic_auth_user_name='TODO: Replace', - two_factor_auth_basic_auth_password='TODO: Replace', + multi_factor_auth_basic_auth_user_name='TODO: Replace', + multi_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, - two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, + multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, + multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/twofactorauth/exceptions/__init__.py b/bandwidth/twofactorauth/exceptions/__init__.py deleted file mode 100644 index 1b04875f..00000000 --- a/bandwidth/twofactorauth/exceptions/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -__all__ = [ - 'error_with_request_exception', - 'unauthorized_request_exception', - 'forbidden_request_exception', -] diff --git a/bandwidth/voice/__init__.py b/bandwidth/voice/__init__.py index 843fbc5d..f7f51aa9 100644 --- a/bandwidth/voice/__init__.py +++ b/bandwidth/voice/__init__.py @@ -1,7 +1,6 @@ -__all__ = [ - 'bxml', +__all__ = [ 'controllers', 'exceptions', 'models', - 'voice_client', + 'voice_client', ] diff --git a/bandwidth/voice/controllers/api_controller.py b/bandwidth/voice/controllers/api_controller.py index 2696af17..d1e44030 100644 --- a/bandwidth/voice/controllers/api_controller.py +++ b/bandwidth/voice/controllers/api_controller.py @@ -18,7 +18,7 @@ from bandwidth.voice.models.conference_detail import ConferenceDetail from bandwidth.voice.models.conference_member_detail import ConferenceMemberDetail from bandwidth.voice.models.conference_recording_metadata_response import ConferenceRecordingMetadataResponse -from bandwidth.voice.exceptions.api_error_response_exception import ApiErrorResponseException +from bandwidth.voice.exceptions.api_error_response_error_exception import ApiErrorResponseErrorException from bandwidth.exceptions.api_exception import APIException @@ -76,19 +76,19 @@ def create_call(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ApiCallResponse.from_dictionary) @@ -141,19 +141,19 @@ def get_call_state(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ApiCallStateResponse.from_dictionary) @@ -208,19 +208,19 @@ def modify_call(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -274,19 +274,19 @@ def modify_call_recording_state(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -339,19 +339,19 @@ def get_query_metadata_for_account_and_call(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) @@ -407,19 +407,19 @@ def get_metadata_for_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) @@ -469,19 +469,19 @@ def delete_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -531,19 +531,19 @@ def get_stream_recording_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = _response.text @@ -593,19 +593,19 @@ def delete_recording_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -660,19 +660,19 @@ def get_recording_transcription(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TranscriptionResponse.from_dictionary) @@ -730,21 +730,21 @@ def create_transcribe_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 410: - raise ApiErrorResponseException('The media for this recording has been deleted, so we can\'t transcribe it', _response) + raise ApiErrorResponseErrorException('The media for this recording has been deleted, so we can\'t transcribe it', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -793,19 +793,19 @@ def delete_recording_transcription(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -876,19 +876,19 @@ def get_conferences_by_account(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceDetail.from_dictionary) @@ -941,19 +941,19 @@ def get_conference_by_id(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceDetail.from_dictionary) @@ -1008,19 +1008,19 @@ def modify_conference(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -1077,19 +1077,19 @@ def modify_conference_member(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -1144,19 +1144,19 @@ def get_conference_member(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceMemberDetail.from_dictionary) @@ -1210,19 +1210,19 @@ def get_query_metadata_for_account_and_conference(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceRecordingMetadataResponse.from_dictionary) @@ -1278,19 +1278,19 @@ def get_metadata_for_conference_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) @@ -1341,19 +1341,19 @@ def get_stream_conference_recording_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = _response.text @@ -1425,19 +1425,19 @@ def get_query_metadata_for_account(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) diff --git a/bandwidth/voice/exceptions/__init__.py b/bandwidth/voice/exceptions/__init__.py index ab7800b4..41768019 100644 --- a/bandwidth/voice/exceptions/__init__.py +++ b/bandwidth/voice/exceptions/__init__.py @@ -1,3 +1,3 @@ __all__ = [ - 'api_error_response_exception', + 'api_error_response_error_exception', ] diff --git a/bandwidth/voice/exceptions/api_error_response_exception.py b/bandwidth/voice/exceptions/api_error_response_error_exception.py similarity index 80% rename from bandwidth/voice/exceptions/api_error_response_exception.py rename to bandwidth/voice/exceptions/api_error_response_error_exception.py index 470d35f9..ab96b74e 100644 --- a/bandwidth/voice/exceptions/api_error_response_exception.py +++ b/bandwidth/voice/exceptions/api_error_response_error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ApiErrorResponseException(bandwidth.exceptions.api_exception.APIException): +class ApiErrorResponseErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ApiErrorResponseException class + """Constructor for the ApiErrorResponseErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ApiErrorResponseException, self).__init__(reason, response) + super(ApiErrorResponseErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/voice/models/__init__.py b/bandwidth/voice/models/__init__.py index 7274beaa..9571d6b0 100644 --- a/bandwidth/voice/models/__init__.py +++ b/bandwidth/voice/models/__init__.py @@ -2,6 +2,7 @@ 'api_call_response', 'api_call_state_response', 'api_create_call_request', + 'api_error_response', 'api_modify_call_request', 'api_modify_conference_request', 'api_transcribe_recording_request', diff --git a/bandwidth/voice/models/api_call_state_response.py b/bandwidth/voice/models/api_call_state_response.py index 44e740d7..8412b905 100644 --- a/bandwidth/voice/models/api_call_state_response.py +++ b/bandwidth/voice/models/api_call_state_response.py @@ -23,6 +23,8 @@ class ApiCallStateResponse(object): mfrom (string): TODO: type description here. direction (string): TODO: type description here. state (StateEnum): TODO: type description here. + identity (string): TODO: type description here. + pai (dict): TODO: type description here. start_time (datetime): TODO: type description here. answer_time (datetime): TODO: type description here. end_time (datetime): TODO: type description here. @@ -43,6 +45,8 @@ class ApiCallStateResponse(object): "mfrom": 'from', "direction": 'direction', "state": 'state', + "identity": 'identity', + "pai": 'pai', "start_time": 'startTime', "answer_time": 'answerTime', "end_time": 'endTime', @@ -61,6 +65,8 @@ def __init__(self, mfrom=None, direction=None, state=None, + identity=None, + pai=None, start_time=None, answer_time=None, end_time=None, @@ -79,6 +85,8 @@ def __init__(self, self.mfrom = mfrom self.direction = direction self.state = state + self.identity = identity + self.pai = pai self.start_time = APIHelper.RFC3339DateTime(start_time) if start_time else None self.answer_time = APIHelper.RFC3339DateTime(answer_time) if answer_time else None self.end_time = APIHelper.RFC3339DateTime(end_time) if end_time else None @@ -113,6 +121,8 @@ def from_dictionary(cls, mfrom = dictionary.get('from') direction = dictionary.get('direction') state = dictionary.get('state') + identity = dictionary.get('identity') + pai = dictionary.get('pai') start_time = APIHelper.RFC3339DateTime.from_value(dictionary.get("startTime")).datetime if dictionary.get("startTime") else None answer_time = APIHelper.RFC3339DateTime.from_value(dictionary.get("answerTime")).datetime if dictionary.get("answerTime") else None end_time = APIHelper.RFC3339DateTime.from_value(dictionary.get("endTime")).datetime if dictionary.get("endTime") else None @@ -130,6 +140,8 @@ def from_dictionary(cls, mfrom, direction, state, + identity, + pai, start_time, answer_time, end_time, diff --git a/bandwidth/voice/models/api_error_response.py b/bandwidth/voice/models/api_error_response.py new file mode 100644 index 00000000..5006a51d --- /dev/null +++ b/bandwidth/voice/models/api_error_response.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class ApiErrorResponse(object): + + """Implementation of the 'ApiErrorResponse' model. + + TODO: type model description here. + + Attributes: + mtype (string): TODO: type description here. + description (string): TODO: type description here. + id (string): TODO: type description here. + + """ + + # Create a mapping from Model property names to API property names + _names = { + "mtype": 'type', + "description": 'description', + "id": 'id' + } + + def __init__(self, + mtype=None, + description=None, + id=None): + """Constructor for the ApiErrorResponse class""" + + # Initialize members of the class + self.mtype = mtype + self.description = description + self.id = id + + @classmethod + def from_dictionary(cls, + dictionary): + """Creates an instance of this model from a dictionary + + Args: + dictionary (dictionary): A dictionary representation of the object + as obtained from the deserialization of the server's response. The + keys MUST match property names in the API description. + + Returns: + object: An instance of this structure class. + + """ + if dictionary is None: + return None + + # Extract variables from the dictionary + mtype = dictionary.get('type') + description = dictionary.get('description') + id = dictionary.get('id') + + # Return an object of this model + return cls(mtype, + description, + id) diff --git a/bandwidth/voice/voice_client.py b/bandwidth/voice/voice_client.py index 58a049dd..71a7e27a 100644 --- a/bandwidth/voice/voice_client.py +++ b/bandwidth/voice/voice_client.py @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - two_factor_auth_basic_auth_user_name='TODO: Replace', - two_factor_auth_basic_auth_password='TODO: Replace', + multi_factor_auth_basic_auth_user_name='TODO: Replace', + multi_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, - two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, + multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, + multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/webrtc/controllers/api_controller.py b/bandwidth/webrtc/controllers/api_controller.py index fdac0ff4..a50c3473 100644 --- a/bandwidth/webrtc/controllers/api_controller.py +++ b/bandwidth/webrtc/controllers/api_controller.py @@ -16,7 +16,7 @@ from bandwidth.webrtc.models.session import Session from bandwidth.webrtc.models.subscriptions import Subscriptions from bandwidth.exceptions.api_exception import APIException -from bandwidth.webrtc.exceptions.error_exception import ErrorException +from bandwidth.webrtc.exceptions.error_error_exception import ErrorErrorException class APIController(BaseController): @@ -79,7 +79,7 @@ def create_participant(self, elif _response.status_code == 403: raise APIException('Access Denied', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, AccountsParticipantsResponse.from_dictionary) @@ -137,7 +137,7 @@ def get_participant(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Participant.from_dictionary) @@ -191,7 +191,7 @@ def delete_participant(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -250,7 +250,7 @@ def create_session(self, elif _response.status_code == 403: raise APIException('Access Denied', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Session.from_dictionary) @@ -308,7 +308,7 @@ def get_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Session.from_dictionary) @@ -362,7 +362,7 @@ def delete_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -419,7 +419,7 @@ def list_session_participants(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Participant.from_dictionary) @@ -485,7 +485,7 @@ def add_participant_to_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -543,7 +543,7 @@ def remove_participant_from_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -603,7 +603,7 @@ def get_participant_subscriptions(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Subscriptions.from_dictionary) @@ -673,7 +673,7 @@ def update_participant_subscriptions(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorException('Unexpected Error', _response) + raise ErrorErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type diff --git a/bandwidth/webrtc/exceptions/__init__.py b/bandwidth/webrtc/exceptions/__init__.py index 4d4907bb..424e5fbb 100644 --- a/bandwidth/webrtc/exceptions/__init__.py +++ b/bandwidth/webrtc/exceptions/__init__.py @@ -1,3 +1,3 @@ __all__ = [ - 'error_exception', + 'error_error_exception', ] diff --git a/bandwidth/webrtc/exceptions/error_exception.py b/bandwidth/webrtc/exceptions/error_error_exception.py similarity index 81% rename from bandwidth/webrtc/exceptions/error_exception.py rename to bandwidth/webrtc/exceptions/error_error_exception.py index a3fe4b9d..6224f2ae 100644 --- a/bandwidth/webrtc/exceptions/error_exception.py +++ b/bandwidth/webrtc/exceptions/error_error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ErrorException(bandwidth.exceptions.api_exception.APIException): +class ErrorErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ErrorException class + """Constructor for the ErrorErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ErrorException, self).__init__(reason, response) + super(ErrorErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/webrtc/models/__init__.py b/bandwidth/webrtc/models/__init__.py index 66181a67..071d3465 100644 --- a/bandwidth/webrtc/models/__init__.py +++ b/bandwidth/webrtc/models/__init__.py @@ -3,6 +3,8 @@ 'participant', 'subscriptions', 'participant_subscription', + 'error', 'accounts_participants_response', + 'device_api_version_enum', 'publish_permission_enum', ] diff --git a/bandwidth/webrtc/models/device_api_version_enum.py b/bandwidth/webrtc/models/device_api_version_enum.py new file mode 100644 index 00000000..19153d44 --- /dev/null +++ b/bandwidth/webrtc/models/device_api_version_enum.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class DeviceApiVersionEnum(object): + + """Implementation of the 'DeviceApiVersion' enum. + + Optional field to define the device api version of this participant + + Attributes: + V3: TODO: type description here. + V2: TODO: type description here. + + """ + + V3 = 'v3' + + V2 = 'v2' diff --git a/bandwidth/webrtc/models/error.py b/bandwidth/webrtc/models/error.py new file mode 100644 index 00000000..6782544c --- /dev/null +++ b/bandwidth/webrtc/models/error.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +""" +bandwidth + +This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). +""" + + +class Error(object): + + """Implementation of the 'Error' model. + + TODO: type model description here. + + Attributes: + code (int): TODO: type description here. + message (string): TODO: type description here. + + """ + + # Create a mapping from Model property names to API property names + _names = { + "code": 'code', + "message": 'message' + } + + def __init__(self, + code=None, + message=None): + """Constructor for the Error class""" + + # Initialize members of the class + self.code = code + self.message = message + + @classmethod + def from_dictionary(cls, + dictionary): + """Creates an instance of this model from a dictionary + + Args: + dictionary (dictionary): A dictionary representation of the object + as obtained from the deserialization of the server's response. The + keys MUST match property names in the API description. + + Returns: + object: An instance of this structure class. + + """ + if dictionary is None: + return None + + # Extract variables from the dictionary + code = dictionary.get('code') + message = dictionary.get('message') + + # Return an object of this model + return cls(code, + message) diff --git a/bandwidth/webrtc/models/participant.py b/bandwidth/webrtc/models/participant.py index 1341c2ea..5cff9652 100644 --- a/bandwidth/webrtc/models/participant.py +++ b/bandwidth/webrtc/models/participant.py @@ -24,6 +24,8 @@ class Participant(object): associated with Capped to one subscriptions (Subscriptions): TODO: type description here. tag (string): User defined tag to associate with the participant + device_api_version (DeviceApiVersionEnum): Optional field to define + the device api version of this participant """ @@ -34,7 +36,8 @@ class Participant(object): "publish_permissions": 'publishPermissions', "sessions": 'sessions', "subscriptions": 'subscriptions', - "tag": 'tag' + "tag": 'tag', + "device_api_version": 'deviceApiVersion' } def __init__(self, @@ -43,7 +46,8 @@ def __init__(self, publish_permissions=None, sessions=None, subscriptions=None, - tag=None): + tag=None, + device_api_version='v2'): """Constructor for the Participant class""" # Initialize members of the class @@ -53,6 +57,7 @@ def __init__(self, self.sessions = sessions self.subscriptions = subscriptions self.tag = tag + self.device_api_version = device_api_version @classmethod def from_dictionary(cls, @@ -78,6 +83,7 @@ def from_dictionary(cls, sessions = dictionary.get('sessions') subscriptions = Subscriptions.from_dictionary(dictionary.get('subscriptions')) if dictionary.get('subscriptions') else None tag = dictionary.get('tag') + device_api_version = dictionary.get("deviceApiVersion") if dictionary.get("deviceApiVersion") else 'v2' # Return an object of this model return cls(id, @@ -85,4 +91,5 @@ def from_dictionary(cls, publish_permissions, sessions, subscriptions, - tag) + tag, + device_api_version) diff --git a/bandwidth/webrtc/web_rtc_client.py b/bandwidth/webrtc/web_rtc_client.py index 0541581c..adf2a678 100644 --- a/bandwidth/webrtc/web_rtc_client.py +++ b/bandwidth/webrtc/web_rtc_client.py @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - two_factor_auth_basic_auth_user_name='TODO: Replace', - two_factor_auth_basic_auth_password='TODO: Replace', + multi_factor_auth_basic_auth_user_name='TODO: Replace', + multi_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, - two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, + multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, + multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/requirements.txt b/requirements.txt index 8666a384..c41ed883 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,3 @@ jsonpickle~=1.4, >= 1.4.1 cachecontrol~=0.12.6 python-dateutil~=2.8.1 enum34~=1.1, >=1.1.10 -lxml==4.6.2 diff --git a/setup.py b/setup.py index f4168dc6..a86f39ab 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='bandwidth-sdk', - version='9.0.0', + version='1.0.0', description='Bandwidth\'s set of APIs', long_description=long_description, long_description_content_type="text/markdown", @@ -28,4 +28,4 @@ 'enum34>=1.1.6', 'lxml>=4.3.4' ] -) +) \ No newline at end of file From 9ea21ac9b6f0a838bff2ae0d8808f51019cbc769 Mon Sep 17 00:00:00 2001 From: jmulford-bandwidth Date: Tue, 9 Mar 2021 13:53:47 -0500 Subject: [PATCH 2/3] reverted all changes except for webrtc --- bandwidth/bandwidth_client.py | 14 +- bandwidth/configuration.py | 34 +-- bandwidth/http/auth/__init__.py | 2 +- ..._auth.py => two_factor_auth_basic_auth.py} | 6 +- .../messaging/controllers/api_controller.py | 139 +++++----- bandwidth/messaging/exceptions/__init__.py | 2 +- ...or_exception.py => messaging_exception.py} | 6 +- bandwidth/messaging/messaging_client.py | 8 +- bandwidth/messaging/models/__init__.py | 1 - bandwidth/messaging/models/media.py | 55 +++- .../multifactorauth/exceptions/__init__.py | 5 - .../models/error_with_request.py | 61 ----- .../models/forbidden_request.py | 55 ---- .../models/unauthorized_request.py | 55 ---- .../__init__.py | 2 +- .../controllers/__init__.py | 0 .../controllers/base_controller.py | 0 .../controllers/mfa_controller.py | 54 ++-- .../twofactorauth/exceptions/__init__.py | 5 + .../error_with_request_exception.py} | 6 +- .../forbidden_request_exception.py} | 6 +- .../unauthorized_request_exception.py} | 6 +- .../models/__init__.py | 3 - .../models/two_factor_code_request_schema.py | 0 .../models/two_factor_messaging_response.py | 0 .../models/two_factor_verify_code_response.py | 0 .../two_factor_verify_request_schema.py | 0 .../models/two_factor_voice_response.py | 0 .../two_factor_auth_client.py} | 12 +- bandwidth/voice/__init__.py | 5 +- bandwidth/voice/controllers/api_controller.py | 256 +++++++++--------- bandwidth/voice/exceptions/__init__.py | 2 +- ...ion.py => api_error_response_exception.py} | 6 +- bandwidth/voice/models/__init__.py | 1 - .../voice/models/api_call_state_response.py | 12 - bandwidth/voice/voice_client.py | 8 +- .../webrtc/controllers/api_controller.py | 24 +- bandwidth/webrtc/exceptions/__init__.py | 2 +- ..._error_exception.py => error_exception.py} | 6 +- bandwidth/webrtc/models/__init__.py | 1 - bandwidth/webrtc/models/error.py | 60 ---- bandwidth/webrtc/web_rtc_client.py | 8 +- requirements.txt | 1 + setup.py | 4 +- 44 files changed, 367 insertions(+), 566 deletions(-) rename bandwidth/http/auth/{multi_factor_auth_basic_auth.py => two_factor_auth_basic_auth.py} (79%) rename bandwidth/messaging/exceptions/{messaging_exception_error_exception.py => messaging_exception.py} (79%) delete mode 100644 bandwidth/multifactorauth/exceptions/__init__.py delete mode 100644 bandwidth/multifactorauth/models/error_with_request.py delete mode 100644 bandwidth/multifactorauth/models/forbidden_request.py delete mode 100644 bandwidth/multifactorauth/models/unauthorized_request.py rename bandwidth/{multifactorauth => twofactorauth}/__init__.py (64%) rename bandwidth/{multifactorauth => twofactorauth}/controllers/__init__.py (100%) rename bandwidth/{multifactorauth => twofactorauth}/controllers/base_controller.py (100%) rename bandwidth/{multifactorauth => twofactorauth}/controllers/mfa_controller.py (69%) create mode 100644 bandwidth/twofactorauth/exceptions/__init__.py rename bandwidth/{multifactorauth/exceptions/error_with_request_error_exception.py => twofactorauth/exceptions/error_with_request_exception.py} (79%) rename bandwidth/{multifactorauth/exceptions/forbidden_request_error_exception.py => twofactorauth/exceptions/forbidden_request_exception.py} (79%) rename bandwidth/{multifactorauth/exceptions/unauthorized_request_error_exception.py => twofactorauth/exceptions/unauthorized_request_exception.py} (78%) rename bandwidth/{multifactorauth => twofactorauth}/models/__init__.py (69%) rename bandwidth/{multifactorauth => twofactorauth}/models/two_factor_code_request_schema.py (100%) rename bandwidth/{multifactorauth => twofactorauth}/models/two_factor_messaging_response.py (100%) rename bandwidth/{multifactorauth => twofactorauth}/models/two_factor_verify_code_response.py (100%) rename bandwidth/{multifactorauth => twofactorauth}/models/two_factor_verify_request_schema.py (100%) rename bandwidth/{multifactorauth => twofactorauth}/models/two_factor_voice_response.py (100%) rename bandwidth/{multifactorauth/multi_factor_auth_client.py => twofactorauth/two_factor_auth_client.py} (77%) rename bandwidth/voice/exceptions/{api_error_response_error_exception.py => api_error_response_exception.py} (80%) rename bandwidth/webrtc/exceptions/{error_error_exception.py => error_exception.py} (81%) delete mode 100644 bandwidth/webrtc/models/error.py diff --git a/bandwidth/bandwidth_client.py b/bandwidth/bandwidth_client.py index 85b41674..ab40fdca 100644 --- a/bandwidth/bandwidth_client.py +++ b/bandwidth/bandwidth_client.py @@ -10,7 +10,7 @@ from bandwidth.configuration import Configuration from bandwidth.configuration import Environment from bandwidth.messaging.messaging_client import MessagingClient -from bandwidth.multifactorauth.multi_factor_auth_client import MultiFactorAuthClient +from bandwidth.twofactorauth.two_factor_auth_client import TwoFactorAuthClient from bandwidth.voice.voice_client import VoiceClient from bandwidth.webrtc.web_rtc_client import WebRtcClient @@ -22,8 +22,8 @@ def messaging_client(self): return MessagingClient(config=self.config) @lazy_property - def multi_factor_auth_client(self): - return MultiFactorAuthClient(config=self.config) + def two_factor_auth_client(self): + return TwoFactorAuthClient(config=self.config) @lazy_property def voice_client(self): @@ -38,8 +38,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - multi_factor_auth_basic_auth_user_name='TODO: Replace', - multi_factor_auth_basic_auth_password='TODO: Replace', + two_factor_auth_basic_auth_user_name='TODO: Replace', + two_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -52,8 +52,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, + two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, + two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/configuration.py b/bandwidth/configuration.py index 7c9fd61b..a5071857 100644 --- a/bandwidth/configuration.py +++ b/bandwidth/configuration.py @@ -21,7 +21,7 @@ class Server(Enum): """An enum for API servers""" DEFAULT = 0 MESSAGINGDEFAULT = 1 - MULTIFACTORAUTHDEFAULT = 2 + TWOFACTORAUTHDEFAULT = 2 VOICEDEFAULT = 3 WEBRTCDEFAULT = 4 @@ -63,12 +63,12 @@ def messaging_basic_auth_password(self): return self._messaging_basic_auth_password @property - def multi_factor_auth_basic_auth_user_name(self): - return self._multi_factor_auth_basic_auth_user_name + def two_factor_auth_basic_auth_user_name(self): + return self._two_factor_auth_basic_auth_user_name @property - def multi_factor_auth_basic_auth_password(self): - return self._multi_factor_auth_basic_auth_password + def two_factor_auth_basic_auth_password(self): + return self._two_factor_auth_basic_auth_password @property def voice_basic_auth_user_name(self): @@ -91,8 +91,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - multi_factor_auth_basic_auth_user_name='TODO: Replace', - multi_factor_auth_basic_auth_password='TODO: Replace', + two_factor_auth_basic_auth_user_name='TODO: Replace', + two_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -121,10 +121,10 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, self._messaging_basic_auth_password = messaging_basic_auth_password # The username to use with basic authentication - self._multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name + self._two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name # The password to use with basic authentication - self._multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password + self._two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password # The username to use with basic authentication self._voice_basic_auth_user_name = voice_basic_auth_user_name @@ -145,8 +145,8 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None, environment=None, base_url=None, messaging_basic_auth_user_name=None, messaging_basic_auth_password=None, - multi_factor_auth_basic_auth_user_name=None, - multi_factor_auth_basic_auth_password=None, + two_factor_auth_basic_auth_user_name=None, + two_factor_auth_basic_auth_password=None, voice_basic_auth_user_name=None, voice_basic_auth_password=None, web_rtc_basic_auth_user_name=None, @@ -158,8 +158,8 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None, base_url = base_url or self.base_url messaging_basic_auth_user_name = messaging_basic_auth_user_name or self.messaging_basic_auth_user_name messaging_basic_auth_password = messaging_basic_auth_password or self.messaging_basic_auth_password - multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name or self.multi_factor_auth_basic_auth_user_name - multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password or self.multi_factor_auth_basic_auth_password + two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name or self.two_factor_auth_basic_auth_user_name + two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password or self.two_factor_auth_basic_auth_password voice_basic_auth_user_name = voice_basic_auth_user_name or self.voice_basic_auth_user_name voice_basic_auth_password = voice_basic_auth_password or self.voice_basic_auth_password web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name or self.web_rtc_basic_auth_user_name @@ -170,8 +170,8 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None, backoff_factor=backoff_factor, environment=environment, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, + two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, + two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, @@ -188,14 +188,14 @@ def create_http_client(self): Environment.PRODUCTION: { Server.DEFAULT: 'api.bandwidth.com', Server.MESSAGINGDEFAULT: 'https://messaging.bandwidth.com/api/v2', - Server.MULTIFACTORAUTHDEFAULT: 'https://mfa.bandwidth.com/api/v1', + Server.TWOFACTORAUTHDEFAULT: 'https://mfa.bandwidth.com/api/v1', Server.VOICEDEFAULT: 'https://voice.bandwidth.com', Server.WEBRTCDEFAULT: 'https://api.webrtc.bandwidth.com/v1' }, Environment.CUSTOM: { Server.DEFAULT: '{base_url}', Server.MESSAGINGDEFAULT: '{base_url}', - Server.MULTIFACTORAUTHDEFAULT: '{base_url}', + Server.TWOFACTORAUTHDEFAULT: '{base_url}', Server.VOICEDEFAULT: '{base_url}', Server.WEBRTCDEFAULT: '{base_url}' } diff --git a/bandwidth/http/auth/__init__.py b/bandwidth/http/auth/__init__.py index 666a8cd4..8ce8edd6 100644 --- a/bandwidth/http/auth/__init__.py +++ b/bandwidth/http/auth/__init__.py @@ -1,6 +1,6 @@ __all__ = [ 'messaging_basic_auth', - 'multi_factor_auth_basic_auth', + 'two_factor_auth_basic_auth', 'voice_basic_auth', 'web_rtc_basic_auth', ] diff --git a/bandwidth/http/auth/multi_factor_auth_basic_auth.py b/bandwidth/http/auth/two_factor_auth_basic_auth.py similarity index 79% rename from bandwidth/http/auth/multi_factor_auth_basic_auth.py rename to bandwidth/http/auth/two_factor_auth_basic_auth.py index e1225e12..c370f3ff 100644 --- a/bandwidth/http/auth/multi_factor_auth_basic_auth.py +++ b/bandwidth/http/auth/two_factor_auth_basic_auth.py @@ -9,7 +9,7 @@ import base64 -class MultiFactorAuthBasicAuth: +class TwoFactorAuthBasicAuth: @staticmethod def apply(config, http_request): @@ -22,8 +22,8 @@ def apply(config, http_request): authentication will be added. """ - username = config.multi_factor_auth_basic_auth_user_name - password = config.multi_factor_auth_basic_auth_password + username = config.two_factor_auth_basic_auth_user_name + password = config.two_factor_auth_basic_auth_password joined = "{}:{}".format(username, password) encoded = base64.b64encode(str.encode(joined)).decode('iso-8859-1') header_value = "Basic {}".format(encoded) diff --git a/bandwidth/messaging/controllers/api_controller.py b/bandwidth/messaging/controllers/api_controller.py index 5ab67aea..cfd9ef04 100644 --- a/bandwidth/messaging/controllers/api_controller.py +++ b/bandwidth/messaging/controllers/api_controller.py @@ -15,7 +15,7 @@ from bandwidth.messaging.models.media import Media from bandwidth.messaging.models.bandwidth_messages_list import BandwidthMessagesList from bandwidth.messaging.models.bandwidth_message import BandwidthMessage -from bandwidth.messaging.exceptions.messaging_exception_error_exception import MessagingExceptionErrorException +from bandwidth.messaging.exceptions.messaging_exception import MessagingException class APIController(BaseController): @@ -26,14 +26,14 @@ def __init__(self, config, call_back=None): super(APIController, self).__init__(config, call_back) def list_media(self, - account_id, + user_id, continuation_token=None): - """Does a GET request to /users/{accountId}/media. + """Does a GET request to /users/{userId}/media. listMedia Args: - account_id (string): User's account ID + user_id (string): User's account ID continuation_token (string, optional): Continuation token used to retrieve subsequent media. @@ -51,9 +51,9 @@ def list_media(self, """ # Prepare query URL - _url_path = '/users/{accountId}/media' + _url_path = '/users/{userId}/media' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'accountId': {'value': account_id, 'encode': False} + 'userId': {'value': user_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) _query_builder += _url_path @@ -72,17 +72,17 @@ def list_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) + raise MessagingException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) + raise MessagingException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) + raise MessagingException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingExceptionErrorException('404 Path not found', _response) + raise MessagingException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) + raise MessagingException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) + raise MessagingException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Media.from_dictionary) @@ -90,14 +90,14 @@ def list_media(self, return _result def get_media(self, - account_id, + user_id, media_id): - """Does a GET request to /users/{accountId}/media/{mediaId}. + """Does a GET request to /users/{userId}/media/{mediaId}. getMedia Args: - account_id (string): User's account ID + user_id (string): User's account ID media_id (string): Media ID to retrieve Returns: @@ -114,9 +114,9 @@ def get_media(self, """ # Prepare query URL - _url_path = '/users/{accountId}/media/{mediaId}' + _url_path = '/users/{userId}/media/{mediaId}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'accountId': {'value': account_id, 'encode': False}, + 'userId': {'value': user_id, 'encode': False}, 'mediaId': {'value': media_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) @@ -130,17 +130,17 @@ def get_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) + raise MessagingException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) + raise MessagingException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) + raise MessagingException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingExceptionErrorException('404 Path not found', _response) + raise MessagingException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) + raise MessagingException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) + raise MessagingException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = _response.text @@ -148,18 +148,20 @@ def get_media(self, return _result def upload_media(self, - account_id, + user_id, media_id, + content_length, body, content_type='application/octet-stream', cache_control=None): - """Does a PUT request to /users/{accountId}/media/{mediaId}. + """Does a PUT request to /users/{userId}/media/{mediaId}. uploadMedia Args: - account_id (string): User's account ID + user_id (string): User's account ID media_id (string): The user supplied custom media ID + content_length (long|int): The size of the entity-body body (typing.BinaryIO): TODO: type description here. content_type (string, optional): The media type of the entity-body @@ -180,9 +182,9 @@ def upload_media(self, """ # Prepare query URL - _url_path = '/users/{accountId}/media/{mediaId}' + _url_path = '/users/{userId}/media/{mediaId}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'accountId': {'value': account_id, 'encode': False}, + 'userId': {'value': user_id, 'encode': False}, 'mediaId': {'value': media_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) @@ -199,6 +201,7 @@ def upload_media(self, # Prepare headers _headers = { 'content-type': body_content_type, + 'Content-Length': content_length, 'Cache-Control': cache_control } @@ -209,31 +212,31 @@ def upload_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) + raise MessagingException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) + raise MessagingException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) + raise MessagingException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingExceptionErrorException('404 Path not found', _response) + raise MessagingException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) + raise MessagingException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) + raise MessagingException('429 The rate limit has been reached', _response) self.validate_response(_response) # Return appropriate type return ApiResponse(_response) def delete_media(self, - account_id, + user_id, media_id): - """Does a DELETE request to /users/{accountId}/media/{mediaId}. + """Does a DELETE request to /users/{userId}/media/{mediaId}. deleteMedia Args: - account_id (string): User's account ID + user_id (string): User's account ID media_id (string): The media ID to delete Returns: @@ -249,9 +252,9 @@ def delete_media(self, """ # Prepare query URL - _url_path = '/users/{accountId}/media/{mediaId}' + _url_path = '/users/{userId}/media/{mediaId}' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'accountId': {'value': account_id, 'encode': False}, + 'userId': {'value': user_id, 'encode': False}, 'mediaId': {'value': media_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) @@ -265,24 +268,24 @@ def delete_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) + raise MessagingException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) + raise MessagingException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) + raise MessagingException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingExceptionErrorException('404 Path not found', _response) + raise MessagingException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) + raise MessagingException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) + raise MessagingException('429 The rate limit has been reached', _response) self.validate_response(_response) # Return appropriate type return ApiResponse(_response) def get_messages(self, - account_id, + user_id, message_id=None, source_tn=None, destination_tn=None, @@ -292,12 +295,12 @@ def get_messages(self, to_date_time=None, page_token=None, limit=None): - """Does a GET request to /users/{accountId}/messages. + """Does a GET request to /users/{userId}/messages. getMessages Args: - account_id (string): User's account ID + user_id (string): User's account ID message_id (string, optional): The ID of the message to search for. Special characters need to be encoded using URL encoding source_tn (string, optional): The phone number that sent the @@ -306,7 +309,7 @@ def get_messages(self, the message message_status (string, optional): The status of the message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, - ACCEPTED, UNDELIVERED + DLR_EXPIRED error_code (int, optional): The error code of the message from_date_time (string, optional): The start of the date range to search in ISO 8601 format. Uses the message receive time. The @@ -334,9 +337,9 @@ def get_messages(self, """ # Prepare query URL - _url_path = '/users/{accountId}/messages' + _url_path = '/users/{userId}/messages' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'accountId': {'value': account_id, 'encode': False} + 'userId': {'value': user_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) _query_builder += _url_path @@ -369,17 +372,17 @@ def get_messages(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) + raise MessagingException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) + raise MessagingException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) + raise MessagingException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingExceptionErrorException('404 Path not found', _response) + raise MessagingException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) + raise MessagingException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) + raise MessagingException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, BandwidthMessagesList.from_dictionary) @@ -387,14 +390,14 @@ def get_messages(self, return _result def create_message(self, - account_id, + user_id, body): - """Does a POST request to /users/{accountId}/messages. + """Does a POST request to /users/{userId}/messages. createMessage Args: - account_id (string): User's account ID + user_id (string): User's account ID body (MessageRequest): TODO: type description here. Returns: @@ -411,9 +414,9 @@ def create_message(self, """ # Prepare query URL - _url_path = '/users/{accountId}/messages' + _url_path = '/users/{userId}/messages' _url_path = APIHelper.append_url_with_template_parameters(_url_path, { - 'accountId': {'value': account_id, 'encode': False} + 'userId': {'value': user_id, 'encode': False} }) _query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT) _query_builder += _url_path @@ -432,17 +435,17 @@ def create_message(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise MessagingExceptionErrorException('400 Request is malformed or invalid', _response) + raise MessagingException('400 Request is malformed or invalid', _response) elif _response.status_code == 401: - raise MessagingExceptionErrorException('401 The specified user does not have access to the account', _response) + raise MessagingException('401 The specified user does not have access to the account', _response) elif _response.status_code == 403: - raise MessagingExceptionErrorException('403 The user does not have access to this API', _response) + raise MessagingException('403 The user does not have access to this API', _response) elif _response.status_code == 404: - raise MessagingExceptionErrorException('404 Path not found', _response) + raise MessagingException('404 Path not found', _response) elif _response.status_code == 415: - raise MessagingExceptionErrorException('415 The content-type of the request is incorrect', _response) + raise MessagingException('415 The content-type of the request is incorrect', _response) elif _response.status_code == 429: - raise MessagingExceptionErrorException('429 The rate limit has been reached', _response) + raise MessagingException('429 The rate limit has been reached', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, BandwidthMessage.from_dictionary) diff --git a/bandwidth/messaging/exceptions/__init__.py b/bandwidth/messaging/exceptions/__init__.py index b135f5bb..8d2920ac 100644 --- a/bandwidth/messaging/exceptions/__init__.py +++ b/bandwidth/messaging/exceptions/__init__.py @@ -1,3 +1,3 @@ __all__ = [ - 'messaging_exception_error_exception', + 'messaging_exception', ] diff --git a/bandwidth/messaging/exceptions/messaging_exception_error_exception.py b/bandwidth/messaging/exceptions/messaging_exception.py similarity index 79% rename from bandwidth/messaging/exceptions/messaging_exception_error_exception.py rename to bandwidth/messaging/exceptions/messaging_exception.py index 90f5e28a..283ebde2 100644 --- a/bandwidth/messaging/exceptions/messaging_exception_error_exception.py +++ b/bandwidth/messaging/exceptions/messaging_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class MessagingExceptionErrorException(bandwidth.exceptions.api_exception.APIException): +class MessagingException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the MessagingExceptionErrorException class + """Constructor for the MessagingException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(MessagingExceptionErrorException, self).__init__(reason, response) + super(MessagingException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/messaging/messaging_client.py b/bandwidth/messaging/messaging_client.py index 664b8acc..86b29def 100644 --- a/bandwidth/messaging/messaging_client.py +++ b/bandwidth/messaging/messaging_client.py @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - multi_factor_auth_basic_auth_user_name='TODO: Replace', - multi_factor_auth_basic_auth_password='TODO: Replace', + two_factor_auth_basic_auth_user_name='TODO: Replace', + two_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, + two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, + two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/messaging/models/__init__.py b/bandwidth/messaging/models/__init__.py index 750078eb..ef3a90d5 100644 --- a/bandwidth/messaging/models/__init__.py +++ b/bandwidth/messaging/models/__init__.py @@ -2,7 +2,6 @@ 'bandwidth_messages_list', 'bandwidth_message_item', 'page_info', - 'messaging_exception', 'media', 'tag', 'deferred_result', diff --git a/bandwidth/messaging/models/media.py b/bandwidth/messaging/models/media.py index 1fb9c53e..8309228e 100644 --- a/bandwidth/messaging/models/media.py +++ b/bandwidth/messaging/models/media.py @@ -5,6 +5,7 @@ This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). """ +from bandwidth.messaging.models.tag import Tag class Media(object): @@ -14,29 +15,57 @@ class Media(object): TODO: type model description here. Attributes: + input_stream (object): TODO: type description here. content (string): TODO: type description here. - content_length (int): TODO: type description here. + url (string): TODO: type description here. + content_length (string): TODO: type description here. + content_type (string): TODO: type description here. + tags (list of Tag): TODO: type description here. + user_id (string): User's account ID media_name (string): TODO: type description here. + media_id (string): TODO: type description here. + cache_control (string): TODO: type description here. """ # Create a mapping from Model property names to API property names _names = { + "input_stream": 'inputStream', "content": 'content', + "url": 'url', "content_length": 'contentLength', - "media_name": 'mediaName' + "content_type": 'contentType', + "tags": 'tags', + "user_id": 'userId', + "media_name": 'mediaName', + "media_id": 'mediaId', + "cache_control": 'cacheControl' } def __init__(self, + input_stream=None, content=None, + url=None, content_length=None, - media_name=None): + content_type=None, + tags=None, + user_id=None, + media_name=None, + media_id=None, + cache_control=None): """Constructor for the Media class""" # Initialize members of the class + self.input_stream = input_stream self.content = content + self.url = url self.content_length = content_length + self.content_type = content_type + self.tags = tags + self.user_id = user_id self.media_name = media_name + self.media_id = media_id + self.cache_control = cache_control @classmethod def from_dictionary(cls, @@ -56,11 +85,27 @@ def from_dictionary(cls, return None # Extract variables from the dictionary + input_stream = dictionary.get('inputStream') content = dictionary.get('content') + url = dictionary.get('url') content_length = dictionary.get('contentLength') + content_type = dictionary.get('contentType') + tags = None + if dictionary.get('tags') is not None: + tags = [Tag.from_dictionary(x) for x in dictionary.get('tags')] + user_id = dictionary.get('userId') media_name = dictionary.get('mediaName') + media_id = dictionary.get('mediaId') + cache_control = dictionary.get('cacheControl') # Return an object of this model - return cls(content, + return cls(input_stream, + content, + url, content_length, - media_name) + content_type, + tags, + user_id, + media_name, + media_id, + cache_control) diff --git a/bandwidth/multifactorauth/exceptions/__init__.py b/bandwidth/multifactorauth/exceptions/__init__.py deleted file mode 100644 index dad74063..00000000 --- a/bandwidth/multifactorauth/exceptions/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -__all__ = [ - 'error_with_request_error_exception', - 'forbidden_request_error_exception', - 'unauthorized_request_error_exception', -] diff --git a/bandwidth/multifactorauth/models/error_with_request.py b/bandwidth/multifactorauth/models/error_with_request.py deleted file mode 100644 index 66abc8c6..00000000 --- a/bandwidth/multifactorauth/models/error_with_request.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bandwidth - -This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). -""" - - -class ErrorWithRequest(object): - - """Implementation of the 'ErrorWithRequest' model. - - TODO: type model description here. - - Attributes: - error (string): An error message pertaining to what the issue could - be - request_id (string): The associated requestId from AWS - - """ - - # Create a mapping from Model property names to API property names - _names = { - "error": 'error', - "request_id": 'requestId' - } - - def __init__(self, - error=None, - request_id=None): - """Constructor for the ErrorWithRequest class""" - - # Initialize members of the class - self.error = error - self.request_id = request_id - - @classmethod - def from_dictionary(cls, - dictionary): - """Creates an instance of this model from a dictionary - - Args: - dictionary (dictionary): A dictionary representation of the object - as obtained from the deserialization of the server's response. The - keys MUST match property names in the API description. - - Returns: - object: An instance of this structure class. - - """ - if dictionary is None: - return None - - # Extract variables from the dictionary - error = dictionary.get('error') - request_id = dictionary.get('requestId') - - # Return an object of this model - return cls(error, - request_id) diff --git a/bandwidth/multifactorauth/models/forbidden_request.py b/bandwidth/multifactorauth/models/forbidden_request.py deleted file mode 100644 index 3200574f..00000000 --- a/bandwidth/multifactorauth/models/forbidden_request.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bandwidth - -This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). -""" - - -class ForbiddenRequest(object): - - """Implementation of the 'ForbiddenRequest' model. - - TODO: type model description here. - - Attributes: - message (string): The message containing the reason behind the request - being forbidden - - """ - - # Create a mapping from Model property names to API property names - _names = { - "message": 'Message' - } - - def __init__(self, - message=None): - """Constructor for the ForbiddenRequest class""" - - # Initialize members of the class - self.message = message - - @classmethod - def from_dictionary(cls, - dictionary): - """Creates an instance of this model from a dictionary - - Args: - dictionary (dictionary): A dictionary representation of the object - as obtained from the deserialization of the server's response. The - keys MUST match property names in the API description. - - Returns: - object: An instance of this structure class. - - """ - if dictionary is None: - return None - - # Extract variables from the dictionary - message = dictionary.get('Message') - - # Return an object of this model - return cls(message) diff --git a/bandwidth/multifactorauth/models/unauthorized_request.py b/bandwidth/multifactorauth/models/unauthorized_request.py deleted file mode 100644 index 8e896681..00000000 --- a/bandwidth/multifactorauth/models/unauthorized_request.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bandwidth - -This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). -""" - - -class UnauthorizedRequest(object): - - """Implementation of the 'UnauthorizedRequest' model. - - TODO: type model description here. - - Attributes: - message (string): The message containing the reason behind the request - being unauthorized - - """ - - # Create a mapping from Model property names to API property names - _names = { - "message": 'message' - } - - def __init__(self, - message=None): - """Constructor for the UnauthorizedRequest class""" - - # Initialize members of the class - self.message = message - - @classmethod - def from_dictionary(cls, - dictionary): - """Creates an instance of this model from a dictionary - - Args: - dictionary (dictionary): A dictionary representation of the object - as obtained from the deserialization of the server's response. The - keys MUST match property names in the API description. - - Returns: - object: An instance of this structure class. - - """ - if dictionary is None: - return None - - # Extract variables from the dictionary - message = dictionary.get('message') - - # Return an object of this model - return cls(message) diff --git a/bandwidth/multifactorauth/__init__.py b/bandwidth/twofactorauth/__init__.py similarity index 64% rename from bandwidth/multifactorauth/__init__.py rename to bandwidth/twofactorauth/__init__.py index ba8fd824..dbf8f2d9 100644 --- a/bandwidth/multifactorauth/__init__.py +++ b/bandwidth/twofactorauth/__init__.py @@ -2,5 +2,5 @@ 'controllers', 'exceptions', 'models', - 'multi_factor_auth_client', + 'two_factor_auth_client', ] diff --git a/bandwidth/multifactorauth/controllers/__init__.py b/bandwidth/twofactorauth/controllers/__init__.py similarity index 100% rename from bandwidth/multifactorauth/controllers/__init__.py rename to bandwidth/twofactorauth/controllers/__init__.py diff --git a/bandwidth/multifactorauth/controllers/base_controller.py b/bandwidth/twofactorauth/controllers/base_controller.py similarity index 100% rename from bandwidth/multifactorauth/controllers/base_controller.py rename to bandwidth/twofactorauth/controllers/base_controller.py diff --git a/bandwidth/multifactorauth/controllers/mfa_controller.py b/bandwidth/twofactorauth/controllers/mfa_controller.py similarity index 69% rename from bandwidth/multifactorauth/controllers/mfa_controller.py rename to bandwidth/twofactorauth/controllers/mfa_controller.py index 453d66c5..648ab148 100644 --- a/bandwidth/multifactorauth/controllers/mfa_controller.py +++ b/bandwidth/twofactorauth/controllers/mfa_controller.py @@ -9,14 +9,14 @@ from bandwidth.api_helper import APIHelper from bandwidth.configuration import Server from bandwidth.http.api_response import ApiResponse -from bandwidth.multifactorauth.controllers.base_controller import BaseController -from bandwidth.http.auth.multi_factor_auth_basic_auth import MultiFactorAuthBasicAuth -from bandwidth.multifactorauth.models.two_factor_voice_response import TwoFactorVoiceResponse -from bandwidth.multifactorauth.models.two_factor_messaging_response import TwoFactorMessagingResponse -from bandwidth.multifactorauth.models.two_factor_verify_code_response import TwoFactorVerifyCodeResponse -from bandwidth.multifactorauth.exceptions.error_with_request_error_exception import ErrorWithRequestErrorException -from bandwidth.multifactorauth.exceptions.unauthorized_request_error_exception import UnauthorizedRequestErrorException -from bandwidth.multifactorauth.exceptions.forbidden_request_error_exception import ForbiddenRequestErrorException +from bandwidth.twofactorauth.controllers.base_controller import BaseController +from bandwidth.http.auth.two_factor_auth_basic_auth import TwoFactorAuthBasicAuth +from bandwidth.twofactorauth.models.two_factor_voice_response import TwoFactorVoiceResponse +from bandwidth.twofactorauth.models.two_factor_messaging_response import TwoFactorMessagingResponse +from bandwidth.twofactorauth.models.two_factor_verify_code_response import TwoFactorVerifyCodeResponse +from bandwidth.twofactorauth.exceptions.error_with_request_exception import ErrorWithRequestException +from bandwidth.twofactorauth.exceptions.unauthorized_request_exception import UnauthorizedRequestException +from bandwidth.twofactorauth.exceptions.forbidden_request_exception import ForbiddenRequestException class MFAController(BaseController): @@ -56,7 +56,7 @@ def create_voice_two_factor(self, _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'accountId': {'value': account_id, 'encode': False} }) - _query_builder = self.config.get_base_uri(Server.MULTIFACTORAUTHDEFAULT) + _query_builder = self.config.get_base_uri(Server.TWOFACTORAUTHDEFAULT) _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) @@ -68,18 +68,18 @@ def create_voice_two_factor(self, # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) - MultiFactorAuthBasicAuth.apply(self.config, _request) + TwoFactorAuthBasicAuth.apply(self.config, _request) _response = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ErrorWithRequestErrorException('If there is any issue with values passed in by the user', _response) + raise ErrorWithRequestException('If there is any issue with values passed in by the user', _response) elif _response.status_code == 401: - raise UnauthorizedRequestErrorException('Authentication is either incorrect or not present', _response) + raise UnauthorizedRequestException('Authentication is either incorrect or not present', _response) elif _response.status_code == 403: - raise ForbiddenRequestErrorException('The user is not authorized to access this resource', _response) + raise ForbiddenRequestException('The user is not authorized to access this resource', _response) elif _response.status_code == 500: - raise ErrorWithRequestErrorException('An internal server error occurred', _response) + raise ErrorWithRequestException('An internal server error occurred', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TwoFactorVoiceResponse.from_dictionary) @@ -116,7 +116,7 @@ def create_messaging_two_factor(self, _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'accountId': {'value': account_id, 'encode': False} }) - _query_builder = self.config.get_base_uri(Server.MULTIFACTORAUTHDEFAULT) + _query_builder = self.config.get_base_uri(Server.TWOFACTORAUTHDEFAULT) _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) @@ -128,18 +128,18 @@ def create_messaging_two_factor(self, # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) - MultiFactorAuthBasicAuth.apply(self.config, _request) + TwoFactorAuthBasicAuth.apply(self.config, _request) _response = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ErrorWithRequestErrorException('If there is any issue with values passed in by the user', _response) + raise ErrorWithRequestException('If there is any issue with values passed in by the user', _response) elif _response.status_code == 401: - raise UnauthorizedRequestErrorException('Authentication is either incorrect or not present', _response) + raise UnauthorizedRequestException('Authentication is either incorrect or not present', _response) elif _response.status_code == 403: - raise ForbiddenRequestErrorException('The user is not authorized to access this resource', _response) + raise ForbiddenRequestException('The user is not authorized to access this resource', _response) elif _response.status_code == 500: - raise ErrorWithRequestErrorException('An internal server error occurred', _response) + raise ErrorWithRequestException('An internal server error occurred', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TwoFactorMessagingResponse.from_dictionary) @@ -175,7 +175,7 @@ def create_verify_two_factor(self, _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 'accountId': {'value': account_id, 'encode': False} }) - _query_builder = self.config.get_base_uri(Server.MULTIFACTORAUTHDEFAULT) + _query_builder = self.config.get_base_uri(Server.TWOFACTORAUTHDEFAULT) _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) @@ -187,20 +187,20 @@ def create_verify_two_factor(self, # Prepare and execute request _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) - MultiFactorAuthBasicAuth.apply(self.config, _request) + TwoFactorAuthBasicAuth.apply(self.config, _request) _response = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ErrorWithRequestErrorException('If there is any issue with values passed in by the user', _response) + raise ErrorWithRequestException('If there is any issue with values passed in by the user', _response) elif _response.status_code == 401: - raise UnauthorizedRequestErrorException('Authentication is either incorrect or not present', _response) + raise UnauthorizedRequestException('Authentication is either incorrect or not present', _response) elif _response.status_code == 403: - raise ForbiddenRequestErrorException('The user is not authorized to access this resource', _response) + raise ForbiddenRequestException('The user is not authorized to access this resource', _response) elif _response.status_code == 429: - raise ErrorWithRequestErrorException('The user has made too many bad requests and is temporarily locked out', _response) + raise ErrorWithRequestException('The user has made too many bad requests and is temporarily locked out', _response) elif _response.status_code == 500: - raise ErrorWithRequestErrorException('An internal server error occurred', _response) + raise ErrorWithRequestException('An internal server error occurred', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TwoFactorVerifyCodeResponse.from_dictionary) diff --git a/bandwidth/twofactorauth/exceptions/__init__.py b/bandwidth/twofactorauth/exceptions/__init__.py new file mode 100644 index 00000000..1b04875f --- /dev/null +++ b/bandwidth/twofactorauth/exceptions/__init__.py @@ -0,0 +1,5 @@ +__all__ = [ + 'error_with_request_exception', + 'unauthorized_request_exception', + 'forbidden_request_exception', +] diff --git a/bandwidth/multifactorauth/exceptions/error_with_request_error_exception.py b/bandwidth/twofactorauth/exceptions/error_with_request_exception.py similarity index 79% rename from bandwidth/multifactorauth/exceptions/error_with_request_error_exception.py rename to bandwidth/twofactorauth/exceptions/error_with_request_exception.py index 09c3eb66..3b606065 100644 --- a/bandwidth/multifactorauth/exceptions/error_with_request_error_exception.py +++ b/bandwidth/twofactorauth/exceptions/error_with_request_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ErrorWithRequestErrorException(bandwidth.exceptions.api_exception.APIException): +class ErrorWithRequestException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ErrorWithRequestErrorException class + """Constructor for the ErrorWithRequestException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ErrorWithRequestErrorException, self).__init__(reason, response) + super(ErrorWithRequestException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/multifactorauth/exceptions/forbidden_request_error_exception.py b/bandwidth/twofactorauth/exceptions/forbidden_request_exception.py similarity index 79% rename from bandwidth/multifactorauth/exceptions/forbidden_request_error_exception.py rename to bandwidth/twofactorauth/exceptions/forbidden_request_exception.py index 7b4502ae..41e5f82e 100644 --- a/bandwidth/multifactorauth/exceptions/forbidden_request_error_exception.py +++ b/bandwidth/twofactorauth/exceptions/forbidden_request_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ForbiddenRequestErrorException(bandwidth.exceptions.api_exception.APIException): +class ForbiddenRequestException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ForbiddenRequestErrorException class + """Constructor for the ForbiddenRequestException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ForbiddenRequestErrorException, self).__init__(reason, response) + super(ForbiddenRequestException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/multifactorauth/exceptions/unauthorized_request_error_exception.py b/bandwidth/twofactorauth/exceptions/unauthorized_request_exception.py similarity index 78% rename from bandwidth/multifactorauth/exceptions/unauthorized_request_error_exception.py rename to bandwidth/twofactorauth/exceptions/unauthorized_request_exception.py index de3e6d0b..d9d8cd11 100644 --- a/bandwidth/multifactorauth/exceptions/unauthorized_request_error_exception.py +++ b/bandwidth/twofactorauth/exceptions/unauthorized_request_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class UnauthorizedRequestErrorException(bandwidth.exceptions.api_exception.APIException): +class UnauthorizedRequestException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the UnauthorizedRequestErrorException class + """Constructor for the UnauthorizedRequestException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(UnauthorizedRequestErrorException, self).__init__(reason, response) + super(UnauthorizedRequestException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/multifactorauth/models/__init__.py b/bandwidth/twofactorauth/models/__init__.py similarity index 69% rename from bandwidth/multifactorauth/models/__init__.py rename to bandwidth/twofactorauth/models/__init__.py index c79f9f19..a22a5a11 100644 --- a/bandwidth/multifactorauth/models/__init__.py +++ b/bandwidth/twofactorauth/models/__init__.py @@ -1,8 +1,5 @@ __all__ = [ 'two_factor_code_request_schema', - 'error_with_request', - 'unauthorized_request', - 'forbidden_request', 'two_factor_voice_response', 'two_factor_messaging_response', 'two_factor_verify_request_schema', diff --git a/bandwidth/multifactorauth/models/two_factor_code_request_schema.py b/bandwidth/twofactorauth/models/two_factor_code_request_schema.py similarity index 100% rename from bandwidth/multifactorauth/models/two_factor_code_request_schema.py rename to bandwidth/twofactorauth/models/two_factor_code_request_schema.py diff --git a/bandwidth/multifactorauth/models/two_factor_messaging_response.py b/bandwidth/twofactorauth/models/two_factor_messaging_response.py similarity index 100% rename from bandwidth/multifactorauth/models/two_factor_messaging_response.py rename to bandwidth/twofactorauth/models/two_factor_messaging_response.py diff --git a/bandwidth/multifactorauth/models/two_factor_verify_code_response.py b/bandwidth/twofactorauth/models/two_factor_verify_code_response.py similarity index 100% rename from bandwidth/multifactorauth/models/two_factor_verify_code_response.py rename to bandwidth/twofactorauth/models/two_factor_verify_code_response.py diff --git a/bandwidth/multifactorauth/models/two_factor_verify_request_schema.py b/bandwidth/twofactorauth/models/two_factor_verify_request_schema.py similarity index 100% rename from bandwidth/multifactorauth/models/two_factor_verify_request_schema.py rename to bandwidth/twofactorauth/models/two_factor_verify_request_schema.py diff --git a/bandwidth/multifactorauth/models/two_factor_voice_response.py b/bandwidth/twofactorauth/models/two_factor_voice_response.py similarity index 100% rename from bandwidth/multifactorauth/models/two_factor_voice_response.py rename to bandwidth/twofactorauth/models/two_factor_voice_response.py diff --git a/bandwidth/multifactorauth/multi_factor_auth_client.py b/bandwidth/twofactorauth/two_factor_auth_client.py similarity index 77% rename from bandwidth/multifactorauth/multi_factor_auth_client.py rename to bandwidth/twofactorauth/two_factor_auth_client.py index 0df23525..f8503d84 100644 --- a/bandwidth/multifactorauth/multi_factor_auth_client.py +++ b/bandwidth/twofactorauth/two_factor_auth_client.py @@ -9,10 +9,10 @@ from bandwidth.decorators import lazy_property from bandwidth.configuration import Configuration from bandwidth.configuration import Environment -from bandwidth.multifactorauth.controllers.mfa_controller import MFAController +from bandwidth.twofactorauth.controllers.mfa_controller import MFAController -class MultiFactorAuthClient(object): +class TwoFactorAuthClient(object): @lazy_property def mfa(self): @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - multi_factor_auth_basic_auth_user_name='TODO: Replace', - multi_factor_auth_basic_auth_password='TODO: Replace', + two_factor_auth_basic_auth_user_name='TODO: Replace', + two_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, + two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, + two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/voice/__init__.py b/bandwidth/voice/__init__.py index f7f51aa9..843fbc5d 100644 --- a/bandwidth/voice/__init__.py +++ b/bandwidth/voice/__init__.py @@ -1,6 +1,7 @@ -__all__ = [ +__all__ = [ + 'bxml', 'controllers', 'exceptions', 'models', - 'voice_client', + 'voice_client', ] diff --git a/bandwidth/voice/controllers/api_controller.py b/bandwidth/voice/controllers/api_controller.py index d1e44030..2696af17 100644 --- a/bandwidth/voice/controllers/api_controller.py +++ b/bandwidth/voice/controllers/api_controller.py @@ -18,7 +18,7 @@ from bandwidth.voice.models.conference_detail import ConferenceDetail from bandwidth.voice.models.conference_member_detail import ConferenceMemberDetail from bandwidth.voice.models.conference_recording_metadata_response import ConferenceRecordingMetadataResponse -from bandwidth.voice.exceptions.api_error_response_error_exception import ApiErrorResponseErrorException +from bandwidth.voice.exceptions.api_error_response_exception import ApiErrorResponseException from bandwidth.exceptions.api_exception import APIException @@ -76,19 +76,19 @@ def create_call(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ApiCallResponse.from_dictionary) @@ -141,19 +141,19 @@ def get_call_state(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ApiCallStateResponse.from_dictionary) @@ -208,19 +208,19 @@ def modify_call(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -274,19 +274,19 @@ def modify_call_recording_state(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -339,19 +339,19 @@ def get_query_metadata_for_account_and_call(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) @@ -407,19 +407,19 @@ def get_metadata_for_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) @@ -469,19 +469,19 @@ def delete_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -531,19 +531,19 @@ def get_stream_recording_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = _response.text @@ -593,19 +593,19 @@ def delete_recording_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -660,19 +660,19 @@ def get_recording_transcription(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, TranscriptionResponse.from_dictionary) @@ -730,21 +730,21 @@ def create_transcribe_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 410: - raise ApiErrorResponseErrorException('The media for this recording has been deleted, so we can\'t transcribe it', _response) + raise ApiErrorResponseException('The media for this recording has been deleted, so we can\'t transcribe it', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -793,19 +793,19 @@ def delete_recording_transcription(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -876,19 +876,19 @@ def get_conferences_by_account(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceDetail.from_dictionary) @@ -941,19 +941,19 @@ def get_conference_by_id(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceDetail.from_dictionary) @@ -1008,19 +1008,19 @@ def modify_conference(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -1077,19 +1077,19 @@ def modify_conference_member(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) # Return appropriate type @@ -1144,19 +1144,19 @@ def get_conference_member(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceMemberDetail.from_dictionary) @@ -1210,19 +1210,19 @@ def get_query_metadata_for_account_and_conference(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, ConferenceRecordingMetadataResponse.from_dictionary) @@ -1278,19 +1278,19 @@ def get_metadata_for_conference_recording(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) @@ -1341,19 +1341,19 @@ def get_stream_conference_recording_media(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = _response.text @@ -1425,19 +1425,19 @@ def get_query_metadata_for_account(self, # Endpoint and global error handling using HTTP status codes. if _response.status_code == 400: - raise ApiErrorResponseErrorException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) + raise ApiErrorResponseException('Something\'s not quite right... Your request is invalid. Please fix it before trying again.', _response) elif _response.status_code == 401: raise APIException('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.', _response) elif _response.status_code == 403: - raise ApiErrorResponseErrorException('User unauthorized to perform this action.', _response) + raise ApiErrorResponseException('User unauthorized to perform this action.', _response) elif _response.status_code == 404: - raise ApiErrorResponseErrorException('The resource specified cannot be found or does not belong to you.', _response) + raise ApiErrorResponseException('The resource specified cannot be found or does not belong to you.', _response) elif _response.status_code == 415: - raise ApiErrorResponseErrorException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) + raise ApiErrorResponseException('We don\'t support that media type. If a request body is required, please send it to us as `application/json`.', _response) elif _response.status_code == 429: - raise ApiErrorResponseErrorException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) + raise ApiErrorResponseException('You\'re sending requests to this endpoint too frequently. Please slow your request rate down and try again.', _response) elif _response.status_code == 500: - raise ApiErrorResponseErrorException('Something unexpected happened. Please try again.', _response) + raise ApiErrorResponseException('Something unexpected happened. Please try again.', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, RecordingMetadataResponse.from_dictionary) diff --git a/bandwidth/voice/exceptions/__init__.py b/bandwidth/voice/exceptions/__init__.py index 41768019..ab7800b4 100644 --- a/bandwidth/voice/exceptions/__init__.py +++ b/bandwidth/voice/exceptions/__init__.py @@ -1,3 +1,3 @@ __all__ = [ - 'api_error_response_error_exception', + 'api_error_response_exception', ] diff --git a/bandwidth/voice/exceptions/api_error_response_error_exception.py b/bandwidth/voice/exceptions/api_error_response_exception.py similarity index 80% rename from bandwidth/voice/exceptions/api_error_response_error_exception.py rename to bandwidth/voice/exceptions/api_error_response_exception.py index ab96b74e..470d35f9 100644 --- a/bandwidth/voice/exceptions/api_error_response_error_exception.py +++ b/bandwidth/voice/exceptions/api_error_response_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ApiErrorResponseErrorException(bandwidth.exceptions.api_exception.APIException): +class ApiErrorResponseException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ApiErrorResponseErrorException class + """Constructor for the ApiErrorResponseException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ApiErrorResponseErrorException, self).__init__(reason, response) + super(ApiErrorResponseException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/voice/models/__init__.py b/bandwidth/voice/models/__init__.py index 9571d6b0..7274beaa 100644 --- a/bandwidth/voice/models/__init__.py +++ b/bandwidth/voice/models/__init__.py @@ -2,7 +2,6 @@ 'api_call_response', 'api_call_state_response', 'api_create_call_request', - 'api_error_response', 'api_modify_call_request', 'api_modify_conference_request', 'api_transcribe_recording_request', diff --git a/bandwidth/voice/models/api_call_state_response.py b/bandwidth/voice/models/api_call_state_response.py index 8412b905..44e740d7 100644 --- a/bandwidth/voice/models/api_call_state_response.py +++ b/bandwidth/voice/models/api_call_state_response.py @@ -23,8 +23,6 @@ class ApiCallStateResponse(object): mfrom (string): TODO: type description here. direction (string): TODO: type description here. state (StateEnum): TODO: type description here. - identity (string): TODO: type description here. - pai (dict): TODO: type description here. start_time (datetime): TODO: type description here. answer_time (datetime): TODO: type description here. end_time (datetime): TODO: type description here. @@ -45,8 +43,6 @@ class ApiCallStateResponse(object): "mfrom": 'from', "direction": 'direction', "state": 'state', - "identity": 'identity', - "pai": 'pai', "start_time": 'startTime', "answer_time": 'answerTime', "end_time": 'endTime', @@ -65,8 +61,6 @@ def __init__(self, mfrom=None, direction=None, state=None, - identity=None, - pai=None, start_time=None, answer_time=None, end_time=None, @@ -85,8 +79,6 @@ def __init__(self, self.mfrom = mfrom self.direction = direction self.state = state - self.identity = identity - self.pai = pai self.start_time = APIHelper.RFC3339DateTime(start_time) if start_time else None self.answer_time = APIHelper.RFC3339DateTime(answer_time) if answer_time else None self.end_time = APIHelper.RFC3339DateTime(end_time) if end_time else None @@ -121,8 +113,6 @@ def from_dictionary(cls, mfrom = dictionary.get('from') direction = dictionary.get('direction') state = dictionary.get('state') - identity = dictionary.get('identity') - pai = dictionary.get('pai') start_time = APIHelper.RFC3339DateTime.from_value(dictionary.get("startTime")).datetime if dictionary.get("startTime") else None answer_time = APIHelper.RFC3339DateTime.from_value(dictionary.get("answerTime")).datetime if dictionary.get("answerTime") else None end_time = APIHelper.RFC3339DateTime.from_value(dictionary.get("endTime")).datetime if dictionary.get("endTime") else None @@ -140,8 +130,6 @@ def from_dictionary(cls, mfrom, direction, state, - identity, - pai, start_time, answer_time, end_time, diff --git a/bandwidth/voice/voice_client.py b/bandwidth/voice/voice_client.py index 71a7e27a..58a049dd 100644 --- a/bandwidth/voice/voice_client.py +++ b/bandwidth/voice/voice_client.py @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - multi_factor_auth_basic_auth_user_name='TODO: Replace', - multi_factor_auth_basic_auth_password='TODO: Replace', + two_factor_auth_basic_auth_user_name='TODO: Replace', + two_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, + two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, + two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/bandwidth/webrtc/controllers/api_controller.py b/bandwidth/webrtc/controllers/api_controller.py index a50c3473..fdac0ff4 100644 --- a/bandwidth/webrtc/controllers/api_controller.py +++ b/bandwidth/webrtc/controllers/api_controller.py @@ -16,7 +16,7 @@ from bandwidth.webrtc.models.session import Session from bandwidth.webrtc.models.subscriptions import Subscriptions from bandwidth.exceptions.api_exception import APIException -from bandwidth.webrtc.exceptions.error_error_exception import ErrorErrorException +from bandwidth.webrtc.exceptions.error_exception import ErrorException class APIController(BaseController): @@ -79,7 +79,7 @@ def create_participant(self, elif _response.status_code == 403: raise APIException('Access Denied', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, AccountsParticipantsResponse.from_dictionary) @@ -137,7 +137,7 @@ def get_participant(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Participant.from_dictionary) @@ -191,7 +191,7 @@ def delete_participant(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -250,7 +250,7 @@ def create_session(self, elif _response.status_code == 403: raise APIException('Access Denied', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Session.from_dictionary) @@ -308,7 +308,7 @@ def get_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Session.from_dictionary) @@ -362,7 +362,7 @@ def delete_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -419,7 +419,7 @@ def list_session_participants(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Participant.from_dictionary) @@ -485,7 +485,7 @@ def add_participant_to_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -543,7 +543,7 @@ def remove_participant_from_session(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type @@ -603,7 +603,7 @@ def get_participant_subscriptions(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) decoded = APIHelper.json_deserialize(_response.text, Subscriptions.from_dictionary) @@ -673,7 +673,7 @@ def update_participant_subscriptions(self, elif _response.status_code == 404: raise APIException('Not Found', _response) elif (_response.status_code < 200) or (_response.status_code > 208): - raise ErrorErrorException('Unexpected Error', _response) + raise ErrorException('Unexpected Error', _response) self.validate_response(_response) # Return appropriate type diff --git a/bandwidth/webrtc/exceptions/__init__.py b/bandwidth/webrtc/exceptions/__init__.py index 424e5fbb..4d4907bb 100644 --- a/bandwidth/webrtc/exceptions/__init__.py +++ b/bandwidth/webrtc/exceptions/__init__.py @@ -1,3 +1,3 @@ __all__ = [ - 'error_error_exception', + 'error_exception', ] diff --git a/bandwidth/webrtc/exceptions/error_error_exception.py b/bandwidth/webrtc/exceptions/error_exception.py similarity index 81% rename from bandwidth/webrtc/exceptions/error_error_exception.py rename to bandwidth/webrtc/exceptions/error_exception.py index 6224f2ae..a3fe4b9d 100644 --- a/bandwidth/webrtc/exceptions/error_error_exception.py +++ b/bandwidth/webrtc/exceptions/error_exception.py @@ -10,9 +10,9 @@ import bandwidth.exceptions.api_exception -class ErrorErrorException(bandwidth.exceptions.api_exception.APIException): +class ErrorException(bandwidth.exceptions.api_exception.APIException): def __init__(self, reason, response): - """Constructor for the ErrorErrorException class + """Constructor for the ErrorException class Args: reason (string): The reason (or error message) for the Exception @@ -20,7 +20,7 @@ def __init__(self, reason, response): response (HttpResponse): The HttpResponse of the API call. """ - super(ErrorErrorException, self).__init__(reason, response) + super(ErrorException, self).__init__(reason, response) dictionary = APIHelper.json_deserialize(self.response.text) if isinstance(dictionary, dict): self.unbox(dictionary) diff --git a/bandwidth/webrtc/models/__init__.py b/bandwidth/webrtc/models/__init__.py index 071d3465..947920dc 100644 --- a/bandwidth/webrtc/models/__init__.py +++ b/bandwidth/webrtc/models/__init__.py @@ -3,7 +3,6 @@ 'participant', 'subscriptions', 'participant_subscription', - 'error', 'accounts_participants_response', 'device_api_version_enum', 'publish_permission_enum', diff --git a/bandwidth/webrtc/models/error.py b/bandwidth/webrtc/models/error.py deleted file mode 100644 index 6782544c..00000000 --- a/bandwidth/webrtc/models/error.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bandwidth - -This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). -""" - - -class Error(object): - - """Implementation of the 'Error' model. - - TODO: type model description here. - - Attributes: - code (int): TODO: type description here. - message (string): TODO: type description here. - - """ - - # Create a mapping from Model property names to API property names - _names = { - "code": 'code', - "message": 'message' - } - - def __init__(self, - code=None, - message=None): - """Constructor for the Error class""" - - # Initialize members of the class - self.code = code - self.message = message - - @classmethod - def from_dictionary(cls, - dictionary): - """Creates an instance of this model from a dictionary - - Args: - dictionary (dictionary): A dictionary representation of the object - as obtained from the deserialization of the server's response. The - keys MUST match property names in the API description. - - Returns: - object: An instance of this structure class. - - """ - if dictionary is None: - return None - - # Extract variables from the dictionary - code = dictionary.get('code') - message = dictionary.get('message') - - # Return an object of this model - return cls(code, - message) diff --git a/bandwidth/webrtc/web_rtc_client.py b/bandwidth/webrtc/web_rtc_client.py index adf2a678..0541581c 100644 --- a/bandwidth/webrtc/web_rtc_client.py +++ b/bandwidth/webrtc/web_rtc_client.py @@ -23,8 +23,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url='https://www.example.com', messaging_basic_auth_user_name='TODO: Replace', messaging_basic_auth_password='TODO: Replace', - multi_factor_auth_basic_auth_user_name='TODO: Replace', - multi_factor_auth_basic_auth_password='TODO: Replace', + two_factor_auth_basic_auth_user_name='TODO: Replace', + two_factor_auth_basic_auth_password='TODO: Replace', voice_basic_auth_user_name='TODO: Replace', voice_basic_auth_password='TODO: Replace', web_rtc_basic_auth_user_name='TODO: Replace', @@ -37,8 +37,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0, base_url=base_url, messaging_basic_auth_user_name=messaging_basic_auth_user_name, messaging_basic_auth_password=messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name=multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password=multi_factor_auth_basic_auth_password, + two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name, + two_factor_auth_basic_auth_password=two_factor_auth_basic_auth_password, voice_basic_auth_user_name=voice_basic_auth_user_name, voice_basic_auth_password=voice_basic_auth_password, web_rtc_basic_auth_user_name=web_rtc_basic_auth_user_name, diff --git a/requirements.txt b/requirements.txt index c41ed883..8666a384 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ jsonpickle~=1.4, >= 1.4.1 cachecontrol~=0.12.6 python-dateutil~=2.8.1 enum34~=1.1, >=1.1.10 +lxml==4.6.2 diff --git a/setup.py b/setup.py index a86f39ab..988c79a5 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='bandwidth-sdk', - version='1.0.0', + version='9.1.0', description='Bandwidth\'s set of APIs', long_description=long_description, long_description_content_type="text/markdown", @@ -28,4 +28,4 @@ 'enum34>=1.1.6', 'lxml>=4.3.4' ] -) \ No newline at end of file +) From 2375201dd7bdaa80b0fcf745a134fa11e5850248 Mon Sep 17 00:00:00 2001 From: jmulford-bandwidth Date: Tue, 9 Mar 2021 13:55:42 -0500 Subject: [PATCH 3/3] removed more files --- .../messaging/models/messaging_exception.py | 60 ----------------- bandwidth/voice/models/api_error_response.py | 66 ------------------- 2 files changed, 126 deletions(-) delete mode 100644 bandwidth/messaging/models/messaging_exception.py delete mode 100644 bandwidth/voice/models/api_error_response.py diff --git a/bandwidth/messaging/models/messaging_exception.py b/bandwidth/messaging/models/messaging_exception.py deleted file mode 100644 index ac899a87..00000000 --- a/bandwidth/messaging/models/messaging_exception.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bandwidth - -This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). -""" - - -class MessagingException(object): - - """Implementation of the 'MessagingException' model. - - TODO: type model description here. - - Attributes: - mtype (string): TODO: type description here. - description (string): TODO: type description here. - - """ - - # Create a mapping from Model property names to API property names - _names = { - "mtype": 'type', - "description": 'description' - } - - def __init__(self, - mtype=None, - description=None): - """Constructor for the MessagingException class""" - - # Initialize members of the class - self.mtype = mtype - self.description = description - - @classmethod - def from_dictionary(cls, - dictionary): - """Creates an instance of this model from a dictionary - - Args: - dictionary (dictionary): A dictionary representation of the object - as obtained from the deserialization of the server's response. The - keys MUST match property names in the API description. - - Returns: - object: An instance of this structure class. - - """ - if dictionary is None: - return None - - # Extract variables from the dictionary - mtype = dictionary.get('type') - description = dictionary.get('description') - - # Return an object of this model - return cls(mtype, - description) diff --git a/bandwidth/voice/models/api_error_response.py b/bandwidth/voice/models/api_error_response.py deleted file mode 100644 index 5006a51d..00000000 --- a/bandwidth/voice/models/api_error_response.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bandwidth - -This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ). -""" - - -class ApiErrorResponse(object): - - """Implementation of the 'ApiErrorResponse' model. - - TODO: type model description here. - - Attributes: - mtype (string): TODO: type description here. - description (string): TODO: type description here. - id (string): TODO: type description here. - - """ - - # Create a mapping from Model property names to API property names - _names = { - "mtype": 'type', - "description": 'description', - "id": 'id' - } - - def __init__(self, - mtype=None, - description=None, - id=None): - """Constructor for the ApiErrorResponse class""" - - # Initialize members of the class - self.mtype = mtype - self.description = description - self.id = id - - @classmethod - def from_dictionary(cls, - dictionary): - """Creates an instance of this model from a dictionary - - Args: - dictionary (dictionary): A dictionary representation of the object - as obtained from the deserialization of the server's response. The - keys MUST match property names in the API description. - - Returns: - object: An instance of this structure class. - - """ - if dictionary is None: - return None - - # Extract variables from the dictionary - mtype = dictionary.get('type') - description = dictionary.get('description') - id = dictionary.get('id') - - # Return an object of this model - return cls(mtype, - description, - id)