Skip to content

Commit 6af1ded

Browse files
authored
fix: Regional API domain processing (#907)
1 parent 654e72a commit 6af1ded

2 files changed

Lines changed: 1 addition & 55 deletions

File tree

tests/unit/rest/test_client.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,36 +78,6 @@ def test_periods_in_query(self):
7878
"https://api.edge.region.twilio.com/path/to/something.json?foo=12.34",
7979
)
8080

81-
def test_edge_deprecation_warning_when_only_edge_is_set(self):
82-
with warnings.catch_warnings(record=True) as w:
83-
warnings.simplefilter("always") # Ensure all warnings are caught
84-
Client(
85-
username="username", password="password", edge="edge"
86-
) # Trigger the warning
87-
88-
# Check if a warning was raised
89-
self.assertGreater(len(w), 0)
90-
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
91-
self.assertIn(
92-
"For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.",
93-
str(w[-1].message),
94-
)
95-
96-
def test_edge_deprecation_warning_when_only_region_is_set(self):
97-
with warnings.catch_warnings(record=True) as w:
98-
warnings.simplefilter("always") # Ensure all warnings are caught
99-
Client(
100-
username="username", password="password", region="us1"
101-
) # Trigger the warning
102-
103-
# Check if a warning was raised
104-
self.assertGreater(len(w), 0)
105-
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
106-
self.assertIn(
107-
"For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.",
108-
str(w[-1].message),
109-
)
110-
11181

11282
class TestUserAgentClients(unittest.TestCase):
11383
def setUp(self):

twilio/base/client_base.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@
1414
class ClientBase(object):
1515
"""A client for accessing the Twilio API."""
1616

17-
region_mappings = {
18-
"au1": "sydney",
19-
"br1": "sao-paulo",
20-
"de1": "frankfurt",
21-
"ie1": "dublin",
22-
"jp1": "tokyo",
23-
"jp2": "osaka",
24-
"sg1": "singapore",
25-
"us1": "ashburn",
26-
"us2": "umatilla",
27-
}
28-
2917
def __init__(
3018
self,
3119
username: Optional[str] = None,
@@ -58,19 +46,7 @@ def __init__(
5846
""" :type : str """
5947
self.password = password or environment.get("TWILIO_AUTH_TOKEN")
6048
""" :type : str """
61-
if (edge is not None and region is None) or (
62-
region is not None and edge is None
63-
):
64-
warnings.warn(
65-
"For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.",
66-
DeprecationWarning,
67-
stacklevel=2,
68-
)
69-
self.edge = (
70-
edge
71-
or environment.get("TWILIO_EDGE")
72-
or (self.region_mappings[region] if region is not None else "")
73-
)
49+
self.edge = ( edge or environment.get("TWILIO_EDGE"))
7450
""" :type : str """
7551
self.region = region or environment.get("TWILIO_REGION")
7652
""" :type : str """

0 commit comments

Comments
 (0)