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

feat: add return types to shortcuts #654

Merged
merged 3 commits into from
Feb 15, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions twilio/rest/accounts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from twilio.rest.accounts import AccountsBase
from warnings import warn

from twilio.rest.accounts import AccountsBase
from twilio.rest.accounts.v1.auth_token_promotion import AuthTokenPromotionList
from twilio.rest.accounts.v1.credential import CredentialList
from twilio.rest.accounts.v1.secondary_auth_token import SecondaryAuthTokenList


class Accounts(AccountsBase):

@property
def auth_token_promotion(self):
def auth_token_promotion(self) -> AuthTokenPromotionList:
warn('auth_token_promotion is deprecated. Use v1.auth_token_promotion instead.', DeprecationWarning, stacklevel=2)
return self.v1.auth_token_promotion

@property
def credentials(self):
def credentials(self) -> CredentialList:
warn('credentials is deprecated. Use v1.credentials instead.', DeprecationWarning, stacklevel=2)
return self.v1.credentials

@property
def secondary_auth_token(self):
def secondary_auth_token(self) -> SecondaryAuthTokenList:
warn('secondary_auth_token is deprecated. Use v1.secondary_auth_token instead.', DeprecationWarning, stacklevel=2)
return self.v1.secondary_auth_token
80 changes: 53 additions & 27 deletions twilio/rest/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,134 +1,160 @@
from twilio.rest.api import ApiBase
from warnings import warn

from twilio.rest.api import ApiBase
from twilio.rest.api.v2010.account import AccountContext, AccountList
from twilio.rest.api.v2010.account.address import AddressList
from twilio.rest.api.v2010.account.application import ApplicationList
from twilio.rest.api.v2010.account.authorized_connect_app import AuthorizedConnectAppList
from twilio.rest.api.v2010.account.available_phone_number_country import AvailablePhoneNumberCountryList
from twilio.rest.api.v2010.account.balance import BalanceList
from twilio.rest.api.v2010.account.call import CallList
from twilio.rest.api.v2010.account.conference import ConferenceList
from twilio.rest.api.v2010.account.connect_app import ConnectAppList
from twilio.rest.api.v2010.account.incoming_phone_number import IncomingPhoneNumberList
from twilio.rest.api.v2010.account.key import KeyList
from twilio.rest.api.v2010.account.message import MessageList
from twilio.rest.api.v2010.account.new_key import NewKeyList
from twilio.rest.api.v2010.account.new_signing_key import NewSigningKeyList
from twilio.rest.api.v2010.account.notification import NotificationList
from twilio.rest.api.v2010.account.outgoing_caller_id import OutgoingCallerIdList
from twilio.rest.api.v2010.account.queue import QueueList
from twilio.rest.api.v2010.account.recording import RecordingList
from twilio.rest.api.v2010.account.short_code import ShortCodeList
from twilio.rest.api.v2010.account.signing_key import SigningKeyList
from twilio.rest.api.v2010.account.sip import SipList
from twilio.rest.api.v2010.account.token import TokenList
from twilio.rest.api.v2010.account.transcription import TranscriptionList
from twilio.rest.api.v2010.account.usage import UsageList
from twilio.rest.api.v2010.account.validation_request import ValidationRequestList


class Api(ApiBase):

@property
def account(self):
def account(self) -> AccountContext:
return self.v2010.account

@property
def accounts(self):
def accounts(self) -> AccountList:
return self.v2010.accounts

@property
def addresses(self):
def addresses(self) -> AddressList:
warn('addresses is deprecated. Use account.addresses instead.', DeprecationWarning, stacklevel=2)
return self.account.addresses

@property
def applications(self):
def applications(self) -> ApplicationList:
warn('applications is deprecated. Use account.applications instead.', DeprecationWarning, stacklevel=2)
return self.account.applications

@property
def authorized_connect_apps(self):
def authorized_connect_apps(self) -> AuthorizedConnectAppList:
warn('authorized_connect_apps is deprecated. Use account.authorized_connect_apps instead.', DeprecationWarning, stacklevel=2)
return self.account.authorized_connect_apps

@property
def available_phone_numbers(self):
def available_phone_numbers(self) -> AvailablePhoneNumberCountryList:
warn('available_phone_numbers is deprecated. Use account.available_phone_numbers instead.', DeprecationWarning, stacklevel=2)
return self.account.available_phone_numbers

@property
def balance(self):
def balance(self) -> BalanceList:
warn('balance is deprecated. Use account.balance instead.', DeprecationWarning, stacklevel=2)
return self.account.balance

@property
def calls(self):
def calls(self) -> CallList:
warn('calls is deprecated. Use account.calls instead.', DeprecationWarning, stacklevel=2)
return self.account.calls

@property
def conferences(self):
def conferences(self) -> ConferenceList:
warn('conferences is deprecated. Use account.conferences instead.', DeprecationWarning, stacklevel=2)
return self.account.conferences

@property
def connect_apps(self):
def connect_apps(self) -> ConnectAppList:
warn('connect_apps is deprecated. Use account.connect_apps instead.', DeprecationWarning, stacklevel=2)
return self.account.connect_apps

@property
def incoming_phone_numbers(self):
def incoming_phone_numbers(self) -> IncomingPhoneNumberList:
warn('incoming_phone_numbers is deprecated. Use account.incoming_phone_numbers instead.', DeprecationWarning, stacklevel=2)
return self.account.incoming_phone_numbers

@property
def keys(self):
def keys(self) -> KeyList:
warn('keys is deprecated. Use account.keys instead.', DeprecationWarning, stacklevel=2)
return self.account.keys

@property
def messages(self):
def messages(self) -> MessageList:
warn('messages is deprecated. Use account.messages instead.', DeprecationWarning, stacklevel=2)
return self.account.messages

@property
def new_keys(self):
def new_keys(self) -> NewKeyList:
warn('new_keys is deprecated. Use account.new_keys instead.', DeprecationWarning, stacklevel=2)
return self.account.new_keys

@property
def new_signing_keys(self):
def new_signing_keys(self) -> NewSigningKeyList:
warn('new_signing_keys is deprecated. Use account.new_signing_keys instead.', DeprecationWarning, stacklevel=2)
return self.account.new_signing_keys

@property
def notifications(self):
def notifications(self) -> NotificationList:
warn('notifications is deprecated. Use account.notifications instead.', DeprecationWarning, stacklevel=2)
return self.account.notifications

@property
def outgoing_caller_ids(self):
def outgoing_caller_ids(self) -> OutgoingCallerIdList:
warn('outgoing_caller_ids is deprecated. Use account.outgoing_caller_ids instead.', DeprecationWarning, stacklevel=2)
return self.account.outgoing_caller_ids

@property
def queues(self):
def queues(self) -> QueueList:
warn('queues is deprecated. Use account.queues instead.', DeprecationWarning, stacklevel=2)
return self.account.queues

@property
def recordings(self):
def recordings(self) -> RecordingList:
warn('recordings is deprecated. Use account.recordings instead.', DeprecationWarning, stacklevel=2)
return self.account.recordings

@property
def signing_keys(self):
def signing_keys(self) -> SigningKeyList:
warn('signing_keys is deprecated. Use account.signing_keys instead.', DeprecationWarning, stacklevel=2)
return self.account.signing_keys

@property
def sip(self):
def sip(self) -> SipList:
warn('sip is deprecated. Use account.sip instead.', DeprecationWarning, stacklevel=2)
return self.account.sip

@property
def short_codes(self):
def short_codes(self) -> ShortCodeList:
warn('short_codes is deprecated. Use account.short_codes instead.', DeprecationWarning, stacklevel=2)
return self.account.short_codes

@property
def tokens(self):
def tokens(self) -> TokenList:
warn('tokens is deprecated. Use account.tokens instead.', DeprecationWarning, stacklevel=2)
return self.account.tokens

@property
def transcriptions(self):
def transcriptions(self) -> TranscriptionList:
warn('transcriptions is deprecated. Use account.transcriptions instead.', DeprecationWarning, stacklevel=2)
return self.account.transcriptions

@property
def usage(self):
def usage(self) -> UsageList:
warn('usage is deprecated. Use account.usage instead.', DeprecationWarning, stacklevel=2)
return self.account.usage

@property
def validation_requests(self):
def validation_requests(self) -> ValidationRequestList:
warn('validation_requests is deprecated. Use account.validation_requests instead.', DeprecationWarning, stacklevel=2)
return self.account.validation_requests

9 changes: 6 additions & 3 deletions twilio/rest/autopilot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from twilio.rest.autopilot import AutopilotBase
from warnings import warn

from twilio.rest.autopilot import AutopilotBase
from twilio.rest.autopilot.v1.assistant import AssistantList
from twilio.rest.autopilot.v1.restore_assistant import RestoreAssistantList


class Autopilot(AutopilotBase):

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

@property
def restore_assistant(self):
def restore_assistant(self) -> RestoreAssistantList:
warn('restore_assistant is deprecated. Use v1.restore_assistant instead.', DeprecationWarning, stacklevel=2)
return self.v1.restore_assistant
9 changes: 6 additions & 3 deletions twilio/rest/bulkexports/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from twilio.rest.bulkexports import BulkexportsBase
from warnings import warn

from twilio.rest.bulkexports import BulkexportsBase
from twilio.rest.bulkexports.v1.export import ExportList
from twilio.rest.bulkexports.v1.export_configuration import ExportConfigurationList


class Bulkexports(BulkexportsBase):

@property
def exports(self):
def exports(self) -> ExportList:
warn('exports is deprecated. Use v1.exports instead.', DeprecationWarning, stacklevel=2)
return self.v1.exports

@property
def export_configuration(self):
def export_configuration(self) -> ExportConfigurationList:
warn('export_configuration is deprecated. Use v1.export_configuration instead.', DeprecationWarning, stacklevel=2)
return self.v1.export_configuration
12 changes: 8 additions & 4 deletions twilio/rest/chat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from twilio.rest.chat import ChatBase
from warnings import warn

from twilio.rest.chat import ChatBase
from twilio.rest.chat.v2.credential import CredentialList
from twilio.rest.chat.v2.service import ServiceList
from twilio.rest.chat.v3.channel import ChannelList


class Chat(ChatBase):

@property
def credentials(self):
def credentials(self) -> CredentialList:
warn('credentials is deprecated. Use v2.credentials instead.', DeprecationWarning, stacklevel=2)
return self.v2.credentials

@property
def services(self):
def services(self) -> ServiceList:
warn('services is deprecated. Use v2.services instead.', DeprecationWarning, stacklevel=2)
return self.v2.services

@property
def channels(self):
def channels(self) -> ChannelList:
warn('channels is deprecated. Use v3.channels instead.', DeprecationWarning, stacklevel=2)
return self.v3.channels
12 changes: 10 additions & 2 deletions twilio/rest/content/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from twilio.rest.content import ContentBase
from warnings import warn

from twilio.rest.content import ContentBase
from twilio.rest.content.v1.content import ContentList
from twilio.rest.content.v1.legacy_content import LegacyContentList


class Content(ContentBase):

@property
def contents(self):
def contents(self) -> ContentList:
warn('contents is deprecated. Use v1.contents instead.', DeprecationWarning, stacklevel=2)
return self.v1.contents

@property
def legacy_contents(self) -> LegacyContentList:
warn('legacy_contents is deprecated. Use v1.legacy_contents instead.', DeprecationWarning, stacklevel=2)
return self.v1.legacy_contents
27 changes: 18 additions & 9 deletions twilio/rest/conversations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
from twilio.rest.conversations import ConversationsBase
from warnings import warn

from twilio.rest.conversations import ConversationsBase
from twilio.rest.conversations.v1.address_configuration import AddressConfigurationList
from twilio.rest.conversations.v1.configuration import ConfigurationList
from twilio.rest.conversations.v1.conversation import ConversationList
from twilio.rest.conversations.v1.credential import CredentialList
from twilio.rest.conversations.v1.participant_conversation import ParticipantConversationList
from twilio.rest.conversations.v1.role import RoleList
from twilio.rest.conversations.v1.service import ServiceList
from twilio.rest.conversations.v1.user import UserList


class Conversations(ConversationsBase):

@property
def configuration(self):
def configuration(self) -> ConfigurationList:
warn('configuration is deprecated. Use v1.configuration instead.', DeprecationWarning, stacklevel=2)
return self.v1.configuration

@property
def address_configurations(self):
def address_configurations(self) -> AddressConfigurationList:
warn('address_configurations is deprecated. Use v1.address_configurations instead.', DeprecationWarning, stacklevel=2)
return self.v1.address_configurations

@property
def conversations(self):
def conversations(self) -> ConversationList:
warn('conversations is deprecated. Use v1.conversations instead.', DeprecationWarning, stacklevel=2)
return self.v1.conversations

@property
def credentials(self):
def credentials(self) -> CredentialList:
warn('credentials is deprecated. Use v1.credentials instead.', DeprecationWarning, stacklevel=2)
return self.v1.credentials

@property
def participant_conversations(self):
def participant_conversations(self) -> ParticipantConversationList:
warn('participant_conversations is deprecated. Use v1.participant_conversations instead.', DeprecationWarning, stacklevel=2)
return self.v1.participant_conversations

@property
def roles(self):
def roles(self) -> RoleList:
warn('roles is deprecated. Use v1.roles instead.', DeprecationWarning, stacklevel=2)
return self.v1.roles

@property
def services(self):
def services(self) -> ServiceList:
warn('services is deprecated. Use v1.services instead.', DeprecationWarning, stacklevel=2)
return self.v1.services

@property
def users(self):
def users(self) -> UserList:
warn('users is deprecated. Use v1.users instead.', DeprecationWarning, stacklevel=2)
return self.v1.users
Loading