Skip to content

Commit

Permalink
Merge branch 'main' into asabu_Python_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AsabuHere authored Oct 6, 2024
2 parents 35b5015 + 69b9ae8 commit 76fecab
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 3,394 deletions.
16 changes: 16 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ twilio-python Changelog

Here you can see the full list of changes between each twilio-python release.

[2024-10-03] Version 9.3.3
--------------------------
**Library - Chore**
- [PR #816](https://github.com/twilio/twilio-python/pull/816): add assistants init files. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)!

**Messaging**
- Add A2P external campaign CnpMigration flag

**Numbers**
- Add address sid to portability API

**Verify**
- Add `SnaClientToken` optional parameter on Verification check.
- Add `EnableSnaClientToken` optional parameter for Verification creation.


[2024-09-25] Version 9.3.2
--------------------------
**Accounts**
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name="twilio",
version="9.3.2",
version="9.3.3",
description="Twilio API client and TwiML generator",
author="Twilio",
help_center="https://www.twilio.com/help/contact",
Expand Down
2 changes: 1 addition & 1 deletion twilio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = ("9", "3", "2")
__version_info__ = ("9", "3", "3")
__version__ = ".".join(__version_info__)
56 changes: 56 additions & 0 deletions twilio/rest/assistants/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from warnings import warn

from twilio.rest.assistants import AssistantsBase
from twilio.rest.assistants.v1.assistant import AssistantList
from twilio.rest.assistants.v1.knowledge import KnowledgeList
from twilio.rest.assistants.v1.policy import PolicyList
from twilio.rest.assistants.v1.session import SessionList
from twilio.rest.assistants.v1.tool import ToolList


class Assistants(AssistantsBase):

@property
def assistants(self) -> AssistantList:
warn(
"assistants is deprecated. Use v1.assistants instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.assistants

@property
def knowledge(self) -> KnowledgeList:
warn(
"knowledge is deprecated. Use v1.knowledge instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.knowledge

@property
def policies(self) -> PolicyList:
warn(
"policies is deprecated. Use v1.policies instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.policies

@property
def sessions(self) -> SessionList:
warn(
"sessions is deprecated. Use v1.sessions instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.sessions

@property
def tools(self) -> ToolList:
warn(
"tools is deprecated. Use v1.tools instead.",
DeprecationWarning,
stacklevel=2,
)
return self.v1.tools
2 changes: 1 addition & 1 deletion twilio/rest/iam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from twilio.rest.iam.v1.new_api_key import NewApiKeyList


class Accounts(IamBase):
class Iam(IamBase):
@property
def api_key(self) -> ApiKeyList:
warn(
Expand Down
12 changes: 6 additions & 6 deletions twilio/rest/iam/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from twilio.base.domain import Domain
from twilio.rest.iam.v1.api_key import ApiKeyList
from twilio.rest.iam.v1.get_api_keys import GetApiKeysList
from twilio.rest.iam.v1.new_api_key import NewApiKeyList
from twilio.rest.iam.v1.key import KeyList


class V1(Version):
Expand All @@ -31,7 +31,7 @@ def __init__(self, domain: Domain):
super().__init__(domain, "v1")
self._api_key: Optional[ApiKeyList] = None
self._get_api_keys: Optional[GetApiKeysList] = None
self._new_api_key: Optional[NewApiKeyList] = None
self._keys: Optional[KeyList] = None

@property
def api_key(self) -> ApiKeyList:
Expand All @@ -46,10 +46,10 @@ def get_api_keys(self) -> GetApiKeysList:
return self._get_api_keys

@property
def new_api_key(self) -> NewApiKeyList:
if self._new_api_key is None:
self._new_api_key = NewApiKeyList(self)
return self._new_api_key
def keys(self) -> KeyList:
if self._keys is None:
self._keys = KeyList(self)
return self._keys

def __repr__(self) -> str:
"""
Expand Down
30 changes: 15 additions & 15 deletions twilio/rest/iam/v1/new_api_key.py → twilio/rest/iam/v1/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from twilio.base.version import Version


class NewApiKeyInstance(InstanceResource):
class KeyInstance(InstanceResource):

class Keytype(object):
RESTRICTED = "restricted"
Expand Down Expand Up @@ -56,14 +56,14 @@ def __repr__(self) -> str:
:returns: Machine friendly representation
"""

return "<Twilio.Iam.V1.NewApiKeyInstance>"
return "<Twilio.Iam.V1.KeyInstance>"


class NewApiKeyList(ListResource):
class KeyList(ListResource):

def __init__(self, version: Version):
"""
Initialize the NewApiKeyList
Initialize the KeyList
:param version: Version that contains the resource
Expand All @@ -76,18 +76,18 @@ def create(
self,
account_sid: str,
friendly_name: Union[str, object] = values.unset,
key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset,
key_type: Union["KeyInstance.Keytype", object] = values.unset,
policy: Union[object, object] = values.unset,
) -> NewApiKeyInstance:
) -> KeyInstance:
"""
Create the NewApiKeyInstance
Create the KeyInstance
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource.
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
:param key_type:
:param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys).
:returns: The created NewApiKeyInstance
:returns: The created KeyInstance
"""

data = values.of(
Expand All @@ -104,24 +104,24 @@ def create(
method="POST", uri=self._uri, data=data, headers=headers
)

return NewApiKeyInstance(self._version, payload)
return KeyInstance(self._version, payload)

async def create_async(
self,
account_sid: str,
friendly_name: Union[str, object] = values.unset,
key_type: Union["NewApiKeyInstance.Keytype", object] = values.unset,
key_type: Union["KeyInstance.Keytype", object] = values.unset,
policy: Union[object, object] = values.unset,
) -> NewApiKeyInstance:
) -> KeyInstance:
"""
Asynchronously create the NewApiKeyInstance
Asynchronously create the KeyInstance
:param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource.
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
:param key_type:
:param policy: The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys).
:returns: The created NewApiKeyInstance
:returns: The created KeyInstance
"""

data = values.of(
Expand All @@ -138,12 +138,12 @@ async def create_async(
method="POST", uri=self._uri, data=data, headers=headers
)

return NewApiKeyInstance(self._version, payload)
return KeyInstance(self._version, payload)

def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Iam.V1.NewApiKeyList>"
return "<Twilio.Iam.V1.KeyList>"
24 changes: 20 additions & 4 deletions twilio/rest/numbers/v1/porting_portability.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,39 @@ def _proxy(self) -> "PortingPortabilityContext":
return self._context

def fetch(
self, target_account_sid: Union[str, object] = values.unset
self,
target_account_sid: Union[str, object] = values.unset,
address_sid: Union[str, object] = values.unset,
) -> "PortingPortabilityInstance":
"""
Fetch the PortingPortabilityInstance
:param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account.
:param address_sid: Address Sid of customer to which the number will be ported.
:returns: The fetched PortingPortabilityInstance
"""
return self._proxy.fetch(
target_account_sid=target_account_sid,
address_sid=address_sid,
)

async def fetch_async(
self, target_account_sid: Union[str, object] = values.unset
self,
target_account_sid: Union[str, object] = values.unset,
address_sid: Union[str, object] = values.unset,
) -> "PortingPortabilityInstance":
"""
Asynchronous coroutine to fetch the PortingPortabilityInstance
:param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account.
:param address_sid: Address Sid of customer to which the number will be ported.
:returns: The fetched PortingPortabilityInstance
"""
return await self._proxy.fetch_async(
target_account_sid=target_account_sid,
address_sid=address_sid,
)

def __repr__(self) -> str:
Expand Down Expand Up @@ -142,19 +150,23 @@ def __init__(self, version: Version, phone_number: str):
)

def fetch(
self, target_account_sid: Union[str, object] = values.unset
self,
target_account_sid: Union[str, object] = values.unset,
address_sid: Union[str, object] = values.unset,
) -> PortingPortabilityInstance:
"""
Fetch the PortingPortabilityInstance
:param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account.
:param address_sid: Address Sid of customer to which the number will be ported.
:returns: The fetched PortingPortabilityInstance
"""

data = values.of(
{
"TargetAccountSid": target_account_sid,
"AddressSid": address_sid,
}
)

Expand All @@ -167,19 +179,23 @@ def fetch(
)

async def fetch_async(
self, target_account_sid: Union[str, object] = values.unset
self,
target_account_sid: Union[str, object] = values.unset,
address_sid: Union[str, object] = values.unset,
) -> PortingPortabilityInstance:
"""
Asynchronous coroutine to fetch the PortingPortabilityInstance
:param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account.
:param address_sid: Address Sid of customer to which the number will be ported.
:returns: The fetched PortingPortabilityInstance
"""

data = values.of(
{
"TargetAccountSid": target_account_sid,
"AddressSid": address_sid,
}
)

Expand Down
11 changes: 0 additions & 11 deletions twilio/rest/preview/PreviewBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from twilio.base.domain import Domain
from twilio.rest import Client
from twilio.rest.preview.deployed_devices import DeployedDevices
from twilio.rest.preview.hosted_numbers import HostedNumbers
from twilio.rest.preview.sync import Sync
from twilio.rest.preview.marketplace import Marketplace
Expand All @@ -29,21 +28,11 @@ def __init__(self, twilio: Client):
:returns: Domain for Preview
"""
super().__init__(twilio, "https://preview.twilio.com")
self._deployed_devices: Optional[DeployedDevices] = None
self._hosted_numbers: Optional[HostedNumbers] = None
self._sync: Optional[Sync] = None
self._marketplace: Optional[Marketplace] = None
self._wireless: Optional[Wireless] = None

@property
def deployed_devices(self) -> DeployedDevices:
"""
:returns: Versions deployed_devices of Preview
"""
if self._deployed_devices is None:
self._deployed_devices = DeployedDevices(self)
return self._deployed_devices

@property
def hosted_numbers(self) -> HostedNumbers:
"""
Expand Down
43 changes: 0 additions & 43 deletions twilio/rest/preview/deployed_devices/__init__.py

This file was deleted.

Loading

0 comments on commit 76fecab

Please sign in to comment.