-
Notifications
You must be signed in to change notification settings - Fork 796
fix: Regional API domain processing #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ce48f3f
fix: Regional API domain processing
manisha1997 ac85a00
fix: Regional API domain processing
manisha1997 e53b1f5
fix: Regional API domain processing
manisha1997 750591b
fix: Regional API domain processing
manisha1997 beb961d
fix: Regional API domain processing
manisha1997 ad9c08a
fix: Regional API domain processing
manisha1997 c8e270f
fix: Regional API domain processing
manisha1997 136b1e9
Apply suggestion from @Copilot
manisha1997 15e1ed6
Apply suggestion from @Copilot
manisha1997 10ec296
fix: Regional API domain processing
manisha1997 afebe73
fix: Regional API domain processing
manisha1997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import os | ||
| import platform | ||
| import warnings | ||
| from typing import Dict, List, MutableMapping, Optional, Tuple | ||
| from urllib.parse import urlparse, urlunparse | ||
|
|
||
|
|
@@ -9,10 +10,21 @@ | |
| from twilio.http.response import Response | ||
| from twilio.credential.credential_provider import CredentialProvider | ||
|
|
||
| warnings.simplefilter("always", DeprecationWarning) | ||
manisha1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| class ClientBase(object): | ||
| """A client for accessing the Twilio API.""" | ||
|
|
||
| region_mappings = { | ||
| "au1": "sydney", | ||
| "br1": "sao-paulo", | ||
| "de1": "frankfurt", | ||
| "ie1": "dublin", | ||
| "jp1": "tokyo", | ||
| "jp2": "osaka", | ||
| "sg1": "singapore", | ||
| "us1": "ashburn", | ||
| "us2": "umatilla" | ||
| } | ||
manisha1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def __init__( | ||
| self, | ||
| username: Optional[str] = None, | ||
|
|
@@ -34,7 +46,7 @@ def __init__( | |
| :param region: Twilio Region to make requests to, defaults to 'us1' if an edge is provided | ||
| :param http_client: HttpClient, defaults to TwilioHttpClient | ||
| :param environment: Environment to look for auth details, defaults to os.environ | ||
| :param edge: Twilio Edge to make requests to, defaults to None | ||
| :param edge: (Deprecated) Twilio Edge to make requests to, defaults to None. Will be deprecated from 9.9.0. Twilio is moving towards regional processing. This will be removed from 10.x.x. | ||
manisha1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| :param user_agent_extensions: Additions to the user agent string | ||
| :param credential_provider: credential provider for authentication method that needs to be used | ||
| """ | ||
|
|
@@ -45,7 +57,12 @@ def __init__( | |
| """ :type : str """ | ||
| self.password = password or environment.get("TWILIO_AUTH_TOKEN") | ||
| """ :type : str """ | ||
| self.edge = edge or environment.get("TWILIO_EDGE") | ||
| if edge is not None: | ||
| warnings.warn( | ||
| "`edge` is deprecated and will be removed in a future version. Use `region` instead.", | ||
| DeprecationWarning | ||
manisha1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| self.edge = (self.region_mappings[region] if region is not None else "") or edge or environment.get("TWILIO_EDGE") | ||
manisha1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ :type : str """ | ||
manisha1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.region = region or environment.get("TWILIO_REGION") | ||
| """ :type : str """ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.