Skip to content
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

fix!: refactor internal resource property storage #696

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
  •  
  •  
  •  
67 changes: 20 additions & 47 deletions twilio/rest/accounts/v1/auth_token_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


from datetime import datetime
from typing import Optional
from typing import Any, Dict, Optional
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
Expand All @@ -23,19 +23,27 @@


class AuthTokenPromotionInstance(InstanceResource):
def __init__(self, version, payload):
"""
Initialize the AuthTokenPromotionInstance
"""

"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
:ivar auth_token: The promoted Auth Token that must be used to authenticate future API requests.
:ivar date_created: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
"""

def __init__(self, version: Version, payload: Dict[str, Any]):
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 @@ -54,41 +62,6 @@ def _proxy(self) -> "AuthTokenPromotionContext":
)
return self._context

@property
def account_sid(self) -> 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"]

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

@property
def date_created(self) -> 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"]

@property
def date_updated(self) -> 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"]

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

def update(self) -> "AuthTokenPromotionInstance":
"""
Update the AuthTokenPromotionInstance
Expand Down
81 changes: 25 additions & 56 deletions twilio/rest/accounts/v1/credential/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


from datetime import datetime
from typing import List, Optional
from typing import Any, Dict, List, Optional
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
Expand All @@ -24,23 +24,34 @@


class AwsInstance(InstanceResource):
def __init__(self, version, payload, sid: Optional[str] = None):
"""
Initialize the AwsInstance
"""

"""
:ivar sid: The unique string that we created to identify the AWS resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
"""

def __init__(
self, version: Version, payload: Dict[str, Any], 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 @@ -59,48 +70,6 @@ def _proxy(self) -> "AwsContext":
)
return self._context

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

@property
def account_sid(self) -> 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"]

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

@property
def date_created(self) -> 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"]

@property
def date_updated(self) -> 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"]

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

def delete(self) -> bool:
"""
Deletes the AwsInstance
Expand Down
81 changes: 25 additions & 56 deletions twilio/rest/accounts/v1/credential/public_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


from datetime import datetime
from typing import List, Optional
from typing import Any, Dict, List, Optional
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
Expand All @@ -24,23 +24,34 @@


class PublicKeyInstance(InstanceResource):
def __init__(self, version, payload, sid: Optional[str] = None):
"""
Initialize the PublicKeyInstance
"""

"""
:ivar sid: The unique string that that we created to identify the PublicKey resource.
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Credential that the PublicKey resource belongs to.
:ivar friendly_name: The string that you assigned to describe the resource.
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
"""

def __init__(
self, version: Version, payload: Dict[str, Any], 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 @@ -59,48 +70,6 @@ def _proxy(self) -> "PublicKeyContext":
)
return self._context

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

@property
def account_sid(self) -> 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"]

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

@property
def date_created(self) -> 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"]

@property
def date_updated(self) -> 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"]

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

def delete(self) -> bool:
"""
Deletes the PublicKeyInstance
Expand Down
67 changes: 20 additions & 47 deletions twilio/rest/accounts/v1/secondary_auth_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


from datetime import datetime
from typing import Optional
from typing import Any, Dict, Optional
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
Expand All @@ -23,19 +23,27 @@


class SecondaryAuthTokenInstance(InstanceResource):
def __init__(self, version, payload):
"""
Initialize the SecondaryAuthTokenInstance
"""

"""
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for.
:ivar date_created: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar date_updated: The date and time in UTC when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
:ivar secondary_auth_token: The generated secondary Auth Token that can be used to authenticate future API requests.
:ivar url: The URI for this resource, relative to `https://accounts.twilio.com`
"""

def __init__(self, version: Version, payload: Dict[str, Any]):
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 @@ -54,41 +62,6 @@ def _proxy(self) -> "SecondaryAuthTokenContext":
)
return self._context

@property
def account_sid(self) -> 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"]

@property
def date_created(self) -> 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"]

@property
def date_updated(self) -> 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"]

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

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

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