Skip to content

Commit

Permalink
make prettier run
Browse files Browse the repository at this point in the history
  • Loading branch information
AsabuHere committed Dec 12, 2024
1 parent 824ed9f commit 3670f03
Show file tree
Hide file tree
Showing 13 changed files with 938 additions and 993 deletions.
6 changes: 5 additions & 1 deletion twilio/auth_strategy/token_auth_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def requires_authentication(self) -> bool:
def fetch_token(self):
if self.token is None or self.token == "" or self.is_token_expired(self.token):
with self.lock:
if self.token is None or self.token == "" or self.is_token_expired(self.token):
if (
self.token is None
or self.token == ""
or self.is_token_expired(self.token)
):
self.logger.info("New token fetched for accessing organization API")
self.token = self.token_manager.fetch_access_token()

Expand Down
15 changes: 10 additions & 5 deletions twilio/base/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from urllib.parse import urlparse, urlunparse

from twilio import __version__
from twilio.base.exceptions import TwilioException
from twilio.http import HttpClient
from twilio.http.http_client import TwilioHttpClient
from twilio.http.response import Response
Expand Down Expand Up @@ -99,7 +98,7 @@ def request(
else:
auth = None

if method == 'DELETE':
if method == "DELETE":
del headers["Accept"]

uri = self.get_hostname(uri)
Expand Down Expand Up @@ -148,7 +147,7 @@ async def request_async(
)

headers = self.get_headers(method, headers)
if method == 'DELETE':
if method == "DELETE":
del headers["Accept"]

if self.credential_provider:
Expand All @@ -174,9 +173,15 @@ async def request_async(

def copy_non_none_values(self, data):
if isinstance(data, dict):
return {k: self.copy_non_none_values(v) for k, v in data.items() if v is not None}
return {
k: self.copy_non_none_values(v)
for k, v in data.items()
if v is not None
}
elif isinstance(data, list):
return [self.copy_non_none_values(item) for item in data if item is not None]
return [
self.copy_non_none_values(item) for item in data if item is not None
]
return data

def get_auth(self, auth: Optional[Tuple[str, str]]) -> Tuple[str, str]:
Expand Down
1 change: 0 additions & 1 deletion twilio/rest/preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class Preview(PreviewBase):


@property
def authorization_documents(self) -> AuthorizationDocumentList:
warn(
Expand Down
2 changes: 1 addition & 1 deletion twilio/rest/preview_iam/PreviewIamBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from twilio.rest.preview_iam.v1 import V1
from twilio.rest.preview_iam.versionless import Versionless


class PreviewIamBase(Domain):
def __init__(self, twilio: Client):
"""
Expand All @@ -27,7 +28,6 @@ def __init__(self, twilio: Client):
self._versionless: Optional[Versionless] = None
self._v1: Optional[V1] = None


@property
def versionless(self) -> Versionless:
"""
Expand Down
9 changes: 1 addition & 8 deletions twilio/rest/preview_iam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
from warnings import warn
from twilio.rest.preview_iam.PreviewIamBase import PreviewIamBase

from twilio.rest.preview_iam.versionless.organization.account import (
AccountList,
)
from twilio.rest.preview_iam.versionless.organization.role_assignment import (
RoleAssignmentList,
)
from twilio.rest.preview_iam.v1.authorize import (
AuthorizeList,
)
Expand All @@ -17,12 +10,12 @@
OrganizationList,
)


class PreviewIam(PreviewIamBase):
@property
def organization(self) -> OrganizationList:
return self.versionless.organization


@property
def authorize(self) -> AuthorizeList:
return self.v1.authorize
Expand Down
2 changes: 1 addition & 1 deletion twilio/rest/preview_iam/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, domain: Domain):
super().__init__(domain, "v1")
self._authorize: Optional[AuthorizeList] = None
self._token: Optional[TokenList] = None

@property
def authorize(self) -> AuthorizeList:
if self._authorize is None:
Expand Down
109 changes: 54 additions & 55 deletions twilio/rest/preview_iam/v1/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,116 +12,115 @@
Do not edit the class manually.
"""


from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import deserialize, serialize, values
from typing import Any, Dict, Optional, Union
from twilio.base import values

from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version



class AuthorizeInstance(InstanceResource):

"""
:ivar redirect_to: The callback URL
"""

def __init__(self, version: Version, payload: Dict[str, Any]):
super().__init__(version)


self.redirect_to: Optional[str] = payload.get("redirect_to")




def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""

return '<Twilio.PreviewIam.V1.AuthorizeInstance>'


return "<Twilio.PreviewIam.V1.AuthorizeInstance>"


class AuthorizeList(ListResource):

def __init__(self, version: Version):
"""
Initialize the AuthorizeList
:param version: Version that contains the resource
"""
super().__init__(version)


self._uri = '/authorize'



def fetch(self, response_type: Union[str, object]=values.unset, client_id: Union[str, object]=values.unset, redirect_uri: Union[str, object]=values.unset, scope: Union[str, object]=values.unset, state: Union[str, object]=values.unset) -> AuthorizeInstance:
self._uri = "/authorize"

def fetch(
self,
response_type: Union[str, object] = values.unset,
client_id: Union[str, object] = values.unset,
redirect_uri: Union[str, object] = values.unset,
scope: Union[str, object] = values.unset,
state: Union[str, object] = values.unset,
) -> AuthorizeInstance:
"""
Asynchronously fetch the AuthorizeInstance
:param response_type: Response Type:param client_id: The Client Identifier:param redirect_uri: The url to which response will be redirected to:param scope: The scope of the access request:param state: An opaque value which can be used to maintain state between the request and callback
:returns: The fetched AuthorizeInstance
"""
headers = values.of({
'Content-Type': 'application/x-www-form-urlencoded'
})

params = values.of({
'response_type': response_type,
'client_id': client_id,
'redirect_uri': redirect_uri,
'scope': scope,
'state': state,

})

payload = self._version.fetch(method='GET', uri=self._uri, headers=headers, params=params)
headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

params = values.of(
{
"response_type": response_type,
"client_id": client_id,
"redirect_uri": redirect_uri,
"scope": scope,
"state": state,
}
)

payload = self._version.fetch(
method="GET", uri=self._uri, headers=headers, params=params
)

return AuthorizeInstance(self._version, payload)

async def fetch_async(self, response_type: Union[str, object]=values.unset, client_id: Union[str, object]=values.unset, redirect_uri: Union[str, object]=values.unset, scope: Union[str, object]=values.unset, state: Union[str, object]=values.unset) -> AuthorizeInstance:
async def fetch_async(
self,
response_type: Union[str, object] = values.unset,
client_id: Union[str, object] = values.unset,
redirect_uri: Union[str, object] = values.unset,
scope: Union[str, object] = values.unset,
state: Union[str, object] = values.unset,
) -> AuthorizeInstance:
"""
Asynchronously fetch the AuthorizeInstance
:param response_type: Response Type:param client_id: The Client Identifier:param redirect_uri: The url to which response will be redirected to:param scope: The scope of the access request:param state: An opaque value which can be used to maintain state between the request and callback
:returns: The fetched AuthorizeInstance
"""
headers = values.of({
'Content-Type': 'application/x-www-form-urlencoded'
})

params = values.of({
'response_type': response_type,
'client_id': client_id,
'redirect_uri': redirect_uri,
'scope': scope,
'state': state,

})

payload = await self._version.fetch_async(method='GET', uri=self._uri, headers=headers, params=params)
headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

params = values.of(
{
"response_type": response_type,
"client_id": client_id,
"redirect_uri": redirect_uri,
"scope": scope,
"state": state,
}
)

payload = await self._version.fetch_async(
method="GET", uri=self._uri, headers=headers, params=params
)

return AuthorizeInstance(self._version, payload)



def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return '<Twilio.PreviewIam.V1.AuthorizeList>'

return "<Twilio.PreviewIam.V1.AuthorizeList>"
Loading

0 comments on commit 3670f03

Please sign in to comment.