Skip to content

fix!: refactor internal resource property storage #696

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 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 19 additions & 17 deletions twilio/rest/accounts/v1/auth_token_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def __init__(self, version, payload):
"""
super().__init__(version)

self._properties = {
"account_sid": payload.get("account_sid"),
"auth_token": payload.get("auth_token"),
"date_created": deserialize.iso8601_datetime(payload.get("date_created")),
"date_updated": deserialize.iso8601_datetime(payload.get("date_updated")),
"url": payload.get("url"),
}
self._account_sid: Optional[str] = payload.get("account_sid")
self._auth_token: Optional[str] = payload.get("auth_token")
self._date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self._date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._url: Optional[str] = payload.get("url")

self._solution = {}
self._context: Optional[AuthTokenPromotionContext] = None
Expand All @@ -55,39 +57,39 @@ def _proxy(self) -> "AuthTokenPromotionContext":
return self._context

@property
def account_sid(self) -> str:
def account_sid(self) -> Optional[str]:
"""
:returns: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
"""
return self._properties["account_sid"]
return self._account_sid

@property
def auth_token(self) -> str:
def auth_token(self) -> Optional[str]:
"""
:returns: The promoted Auth Token that must be used to authenticate future API requests.
"""
return self._properties["auth_token"]
return self._auth_token

@property
def date_created(self) -> datetime:
def date_created(self) -> Optional[datetime]:
"""
:returns: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
return self._properties["date_created"]
return self._date_created

@property
def date_updated(self) -> datetime:
def date_updated(self) -> Optional[datetime]:
"""
:returns: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
return self._properties["date_updated"]
return self._date_updated

@property
def url(self) -> str:
def url(self) -> Optional[str]:
"""
:returns: The URI for this resource, relative to `https://accounts.twilio.com`
"""
return self._properties["url"]
return self._url

def update(self) -> "AuthTokenPromotionInstance":
"""
Expand Down
44 changes: 23 additions & 21 deletions twilio/rest/accounts/v1/credential/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ def __init__(self, version, payload, sid: Optional[str] = None):
"""
super().__init__(version)

self._properties = {
"sid": payload.get("sid"),
"account_sid": payload.get("account_sid"),
"friendly_name": payload.get("friendly_name"),
"date_created": deserialize.iso8601_datetime(payload.get("date_created")),
"date_updated": deserialize.iso8601_datetime(payload.get("date_updated")),
"url": payload.get("url"),
}
self._sid: Optional[str] = payload.get("sid")
self._account_sid: Optional[str] = payload.get("account_sid")
self._friendly_name: Optional[str] = payload.get("friendly_name")
self._date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self._date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._url: Optional[str] = payload.get("url")

self._solution = {
"sid": sid or self._properties["sid"],
"sid": sid or self._sid,
}
self._context: Optional[AwsContext] = None

Expand All @@ -60,46 +62,46 @@ def _proxy(self) -> "AwsContext":
return self._context

@property
def sid(self) -> str:
def sid(self) -> Optional[str]:
"""
:returns: The unique string that we created to identify the AWS resource.
"""
return self._properties["sid"]
return self._sid

@property
def account_sid(self) -> str:
def account_sid(self) -> Optional[str]:
"""
:returns: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource.
"""
return self._properties["account_sid"]
return self._account_sid

@property
def friendly_name(self) -> str:
def friendly_name(self) -> Optional[str]:
"""
:returns: The string that you assigned to describe the resource.
"""
return self._properties["friendly_name"]
return self._friendly_name

@property
def date_created(self) -> datetime:
def date_created(self) -> Optional[datetime]:
"""
:returns: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
"""
return self._properties["date_created"]
return self._date_created

@property
def date_updated(self) -> datetime:
def date_updated(self) -> Optional[datetime]:
"""
:returns: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
"""
return self._properties["date_updated"]
return self._date_updated

@property
def url(self) -> str:
def url(self) -> Optional[str]:
"""
:returns: The URI for this resource, relative to `https://accounts.twilio.com`
"""
return self._properties["url"]
return self._url

def delete(self) -> bool:
"""
Expand Down
44 changes: 23 additions & 21 deletions twilio/rest/accounts/v1/credential/public_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ def __init__(self, version, payload, sid: Optional[str] = None):
"""
super().__init__(version)

self._properties = {
"sid": payload.get("sid"),
"account_sid": payload.get("account_sid"),
"friendly_name": payload.get("friendly_name"),
"date_created": deserialize.iso8601_datetime(payload.get("date_created")),
"date_updated": deserialize.iso8601_datetime(payload.get("date_updated")),
"url": payload.get("url"),
}
self._sid: Optional[str] = payload.get("sid")
self._account_sid: Optional[str] = payload.get("account_sid")
self._friendly_name: Optional[str] = payload.get("friendly_name")
self._date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self._date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._url: Optional[str] = payload.get("url")

self._solution = {
"sid": sid or self._properties["sid"],
"sid": sid or self._sid,
}
self._context: Optional[PublicKeyContext] = None

Expand All @@ -60,46 +62,46 @@ def _proxy(self) -> "PublicKeyContext":
return self._context

@property
def sid(self) -> str:
def sid(self) -> Optional[str]:
"""
:returns: The unique string that that we created to identify the PublicKey resource.
"""
return self._properties["sid"]
return self._sid

@property
def account_sid(self) -> str:
def account_sid(self) -> Optional[str]:
"""
:returns: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Credential that the PublicKey resource belongs to.
"""
return self._properties["account_sid"]
return self._account_sid

@property
def friendly_name(self) -> str:
def friendly_name(self) -> Optional[str]:
"""
:returns: The string that you assigned to describe the resource.
"""
return self._properties["friendly_name"]
return self._friendly_name

@property
def date_created(self) -> datetime:
def date_created(self) -> Optional[datetime]:
"""
:returns: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
"""
return self._properties["date_created"]
return self._date_created

@property
def date_updated(self) -> datetime:
def date_updated(self) -> Optional[datetime]:
"""
:returns: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
"""
return self._properties["date_updated"]
return self._date_updated

@property
def url(self) -> str:
def url(self) -> Optional[str]:
"""
:returns: The URI for this resource, relative to `https://accounts.twilio.com`
"""
return self._properties["url"]
return self._url

def delete(self) -> bool:
"""
Expand Down
36 changes: 19 additions & 17 deletions twilio/rest/accounts/v1/secondary_auth_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def __init__(self, version, payload):
"""
super().__init__(version)

self._properties = {
"account_sid": payload.get("account_sid"),
"date_created": deserialize.iso8601_datetime(payload.get("date_created")),
"date_updated": deserialize.iso8601_datetime(payload.get("date_updated")),
"secondary_auth_token": payload.get("secondary_auth_token"),
"url": payload.get("url"),
}
self._account_sid: Optional[str] = payload.get("account_sid")
self._date_created: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_created")
)
self._date_updated: Optional[datetime] = deserialize.iso8601_datetime(
payload.get("date_updated")
)
self._secondary_auth_token: Optional[str] = payload.get("secondary_auth_token")
self._url: Optional[str] = payload.get("url")

self._solution = {}
self._context: Optional[SecondaryAuthTokenContext] = None
Expand All @@ -55,39 +57,39 @@ def _proxy(self) -> "SecondaryAuthTokenContext":
return self._context

@property
def account_sid(self) -> str:
def account_sid(self) -> Optional[str]:
"""
:returns: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
"""
return self._properties["account_sid"]
return self._account_sid

@property
def date_created(self) -> datetime:
def date_created(self) -> Optional[datetime]:
"""
:returns: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
return self._properties["date_created"]
return self._date_created

@property
def date_updated(self) -> datetime:
def date_updated(self) -> Optional[datetime]:
"""
:returns: The date and time in UTC when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
"""
return self._properties["date_updated"]
return self._date_updated

@property
def secondary_auth_token(self) -> str:
def secondary_auth_token(self) -> Optional[str]:
"""
:returns: The generated secondary Auth Token that can be used to authenticate future API requests.
"""
return self._properties["secondary_auth_token"]
return self._secondary_auth_token

@property
def url(self) -> str:
def url(self) -> Optional[str]:
"""
:returns: The URI for this resource, relative to `https://accounts.twilio.com`
"""
return self._properties["url"]
return self._url

def create(self) -> "SecondaryAuthTokenInstance":
"""
Expand Down
Loading