Skip to content

Commit d0950a2

Browse files
committed
Deploy
1 parent 470f3cc commit d0950a2

File tree

73 files changed

+835
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+835
-88
lines changed

bandwidth/bandwidth_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def web_rtc_client(self):
3535

3636
def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
3737
environment=Environment.PRODUCTION,
38+
base_url='https://www.example.com',
3839
messaging_basic_auth_user_name='TODO: Replace',
3940
messaging_basic_auth_password='TODO: Replace',
4041
two_factor_auth_basic_auth_user_name='TODO: Replace',
@@ -48,6 +49,7 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
4849
max_retries=max_retries,
4950
backoff_factor=backoff_factor,
5051
environment=environment,
52+
base_url=base_url,
5153
messaging_basic_auth_user_name=messaging_basic_auth_user_name,
5254
messaging_basic_auth_password=messaging_basic_auth_password,
5355
two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name,

bandwidth/configuration.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
"""
88

99
from enum import Enum
10+
from bandwidth.api_helper import APIHelper
1011
from bandwidth.http.requests_client import RequestsClient
1112

1213

1314
class Environment(Enum):
1415
"""An enum for SDK environments"""
1516
PRODUCTION = 0
17+
CUSTOM = 1
1618

1719

1820
class Server(Enum):
@@ -48,6 +50,10 @@ def backoff_factor(self):
4850
def environment(self):
4951
return self._environment
5052

53+
@property
54+
def base_url(self):
55+
return self._base_url
56+
5157
@property
5258
def messaging_basic_auth_user_name(self):
5359
return self._messaging_basic_auth_user_name
@@ -82,6 +88,7 @@ def web_rtc_basic_auth_password(self):
8288

8389
def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
8490
environment=Environment.PRODUCTION,
91+
base_url='https://www.example.com',
8592
messaging_basic_auth_user_name='TODO: Replace',
8693
messaging_basic_auth_password='TODO: Replace',
8794
two_factor_auth_basic_auth_user_name='TODO: Replace',
@@ -104,6 +111,9 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
104111
# Current API environment
105112
self._environment = environment
106113

114+
# base_url value
115+
self._base_url = base_url
116+
107117
# The username to use with basic authentication
108118
self._messaging_basic_auth_user_name = messaging_basic_auth_user_name
109119

@@ -132,7 +142,8 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
132142
self._http_client = self.create_http_client()
133143

134144
def clone_with(self, timeout=None, max_retries=None, backoff_factor=None,
135-
environment=None, messaging_basic_auth_user_name=None,
145+
environment=None, base_url=None,
146+
messaging_basic_auth_user_name=None,
136147
messaging_basic_auth_password=None,
137148
two_factor_auth_basic_auth_user_name=None,
138149
two_factor_auth_basic_auth_password=None,
@@ -144,6 +155,7 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None,
144155
max_retries = max_retries or self.max_retries
145156
backoff_factor = backoff_factor or self.backoff_factor
146157
environment = environment or self.environment
158+
base_url = base_url or self.base_url
147159
messaging_basic_auth_user_name = messaging_basic_auth_user_name or self.messaging_basic_auth_user_name
148160
messaging_basic_auth_password = messaging_basic_auth_password or self.messaging_basic_auth_password
149161
two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name or self.two_factor_auth_basic_auth_user_name
@@ -155,7 +167,7 @@ def clone_with(self, timeout=None, max_retries=None, backoff_factor=None,
155167

156168
return Configuration(
157169
timeout=timeout, max_retries=max_retries,
158-
backoff_factor=backoff_factor, environment=environment,
170+
backoff_factor=backoff_factor, environment=environment, base_url=base_url,
159171
messaging_basic_auth_user_name=messaging_basic_auth_user_name,
160172
messaging_basic_auth_password=messaging_basic_auth_password,
161173
two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name,
@@ -179,6 +191,13 @@ def create_http_client(self):
179191
Server.TWOFACTORAUTHDEFAULT: 'https://mfa.bandwidth.com/api/v1/',
180192
Server.VOICEDEFAULT: 'https://voice.bandwidth.com',
181193
Server.WEBRTCDEFAULT: 'https://api.webrtc.bandwidth.com/v1'
194+
},
195+
Environment.CUSTOM: {
196+
Server.DEFAULT: '{base_url}',
197+
Server.MESSAGINGDEFAULT: '{base_url}',
198+
Server.TWOFACTORAUTHDEFAULT: '{base_url}',
199+
Server.VOICEDEFAULT: '{base_url}',
200+
Server.WEBRTCDEFAULT: '{base_url}'
182201
}
183202
}
184203

@@ -194,4 +213,10 @@ def get_base_uri(self, server=Server.DEFAULT):
194213
String: The base URI.
195214
196215
"""
197-
return self.environments[self.environment][server]
216+
parameters = {
217+
"base_url": {'value': self.base_url, 'encode': False},
218+
}
219+
220+
return APIHelper.append_url_with_template_parameters(
221+
self.environments[self.environment][server], parameters
222+
)

bandwidth/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BaseController(object):
2828

2929
def global_headers(self):
3030
return {
31-
'user-agent': 'python-sdk-refs/tags/python6.11.0'
31+
'user-agent': 'python-sdk-refs/tags/python6.12.0'
3232
}
3333

3434
def __init__(self, config, call_back=None):

bandwidth/messaging/controllers/api_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def upload_media(self,
161161
user_id (string): TODO: type description here.
162162
media_id (string): TODO: type description here.
163163
content_length (long|int): TODO: type description here.
164-
body (string): TODO: type description here.
164+
body (typing.BinaryIO): TODO: type description here.
165165
content_type (string, optional): TODO: type description here.
166166
Example: application/octet-stream
167167
cache_control (string, optional): TODO: type description here.

bandwidth/messaging/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BaseController(object):
2828

2929
def global_headers(self):
3030
return {
31-
'user-agent': 'python-sdk-refs/tags/python6.11.0'
31+
'user-agent': 'python-sdk-refs/tags/python6.12.0'
3232
}
3333

3434
def __init__(self, config, call_back=None):

bandwidth/messaging/messaging_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def client(self):
2020

2121
def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
2222
environment=Environment.PRODUCTION,
23+
base_url='https://www.example.com',
2324
messaging_basic_auth_user_name='TODO: Replace',
2425
messaging_basic_auth_password='TODO: Replace',
2526
two_factor_auth_basic_auth_user_name='TODO: Replace',
@@ -33,6 +34,7 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
3334
max_retries=max_retries,
3435
backoff_factor=backoff_factor,
3536
environment=environment,
37+
base_url=base_url,
3638
messaging_basic_auth_user_name=messaging_basic_auth_user_name,
3739
messaging_basic_auth_password=messaging_basic_auth_password,
3840
two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name,

bandwidth/twofactorauth/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BaseController(object):
2828

2929
def global_headers(self):
3030
return {
31-
'user-agent': 'python-sdk-refs/tags/python6.11.0'
31+
'user-agent': 'python-sdk-refs/tags/python6.12.0'
3232
}
3333

3434
def __init__(self, config, call_back=None):

bandwidth/twofactorauth/two_factor_auth_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def client(self):
2020

2121
def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
2222
environment=Environment.PRODUCTION,
23+
base_url='https://www.example.com',
2324
messaging_basic_auth_user_name='TODO: Replace',
2425
messaging_basic_auth_password='TODO: Replace',
2526
two_factor_auth_basic_auth_user_name='TODO: Replace',
@@ -33,6 +34,7 @@ def __init__(self, timeout=60, max_retries=3, backoff_factor=0,
3334
max_retries=max_retries,
3435
backoff_factor=backoff_factor,
3536
environment=environment,
37+
base_url=base_url,
3638
messaging_basic_auth_user_name=messaging_basic_auth_user_name,
3739
messaging_basic_auth_password=messaging_basic_auth_password,
3840
two_factor_auth_basic_auth_user_name=two_factor_auth_basic_auth_user_name,

bandwidth/voice/bxml/verbs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
from .start_recording import StartRecording
1616
from .conference import Conference
1717
from .bridge import Bridge
18+
from .ring import Ring

bandwidth/voice/bxml/verbs/bridge.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class Bridge(AbstractBxmlVerb):
1818

1919
def __init__(self, call_id, bridge_complete_url=None, bridge_complete_method=None,
2020
bridge_target_complete_url=None, bridge_target_complete_method=None,
21-
username=None, password=None, tag=None):
21+
username=None, password=None, tag=None, bridge_complete_fallback_url=None,
22+
bridge_complete_fallback_method=None, bridge_target_complete_fallback_url=None,
23+
bridge_target_complete_fallback_method=None, fallback_username=None,
24+
fallback_password=None):
2225
"""
2326
Initializes the Bridge class with the following parameters
2427
@@ -30,6 +33,12 @@ def __init__(self, call_id, bridge_complete_url=None, bridge_complete_method=Non
3033
:param str username: HTTP basic auth username for events
3134
:param str password: HTTP basic auth password for events
3235
:param str tag: Custom tag to include in callbacks
36+
:param str bridge_complete_fallback_url: Fallback url for bridge complete events
37+
:param str bridge_complete_fallback_method: HTTP method for bridge complete fallback
38+
:param str bridge_target_complete_fallback_url: Fallback url for bridge target complete events
39+
:param str bridge_target_complete_fallback_method: HTTP method for bridge target complete fallback
40+
:param str fallback_username: Basic auth username for fallback events
41+
:param str fallback_password: Basic auth password for fallback events
3342
"""
3443
self.call_id = call_id
3544
self.bridge_complete_url = bridge_complete_url
@@ -39,6 +48,12 @@ def __init__(self, call_id, bridge_complete_url=None, bridge_complete_method=Non
3948
self.username = username
4049
self.password = password
4150
self.tag = tag
51+
self.bridge_complete_fallback_url = bridge_complete_fallback_url
52+
self.bridge_complete_fallback_method = bridge_complete_fallback_method
53+
self.bridge_target_complete_fallback_url = bridge_target_complete_fallback_url
54+
self.bridge_target_complete_fallback_method = bridge_target_complete_fallback_method
55+
self.fallback_username = fallback_username
56+
self.fallback_password = fallback_password
4257

4358
def to_bxml(self):
4459
root = etree.Element(BRIDGE_TAG)
@@ -57,4 +72,16 @@ def to_bxml(self):
5772
root.set("password", self.password)
5873
if self.tag is not None:
5974
root.set("tag", self.tag)
75+
if self.bridge_complete_fallback_url is not None:
76+
root.set("bridgeCompleteFallbackUrl", self.bridge_complete_fallback_url)
77+
if self.bridge_complete_fallback_method is not None:
78+
root.set("bridgeCompleteFallbackMethod", self.bridge_complete_fallback_method)
79+
if self.bridge_target_complete_fallback_url is not None:
80+
root.set("bridgeTargetCompleteFallbackUrl", self.bridge_target_complete_fallback_url)
81+
if self.bridge_target_complete_fallback_method is not None:
82+
root.set("bridgeTargetCompleteFallbackMethod", self.bridge_target_complete_fallback_method)
83+
if self.fallback_username is not None:
84+
root.set("fallbackUsername", self.fallback_username)
85+
if self.fallback_password is not None:
86+
root.set("fallbackPassword", self.fallback_password)
6087
return etree.tostring(root).decode()

0 commit comments

Comments
 (0)