diff --git a/CHANGES.md b/CHANGES.md index 60487c62d..22d615d6e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,38 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2026-08-21] Version 9.11.1 +--------------------------- +**Library - Fix** +- [PR #954](https://github.com/twilio/twilio-python/pull/954): Fix tag validation regex in deploy.yml. Thanks to [@kridai](https://github.com/kridai)! + +**Destinations** +- ## 2026-08-12 +- Minor updates (formatting, metadata) +- ## 2026-08-12 +- **Content updates**: +- Added properties to `DestinationType`: releaseStatus +- Removed properties from `DestinationType`: maturity + +**Memory** +- No path changes (updated metadata only) +- `DataMappingType` gains `INGRESS`, `DATASET_CLOUDAPP`, and `DATASET_WAREHOUSE`. +- `CSV` and `DATASET` remain valid and unchanged; they are deprecated aliases and +- will be removed in a follow-up change. +- `DataMappingFromTypes` gains three `oneOf` members and three discriminator keys: +- `DataMappingFromIngress` (renames `DataMappingFromCSV`), +- `DataMappingFromCloudAppDataSet` and `DataMappingFromWarehouseDataSet` +- (both split from `DataMappingFromDataSet`, distinguishing a cloud-app-backed +- TDI dataset from a warehouse-backed one). +- Additive and backwards compatible: existing `CSV` and `DATASET` payloads are +- unaffected. +- ## 2026-08-10 + +**Voice** +- ## 2026-08-05 +- Added GET /v3/Transcriptions to list and filter transcriptions (status, sourceId, languageCode, createdAfter/createdBefore) with pageSize/pageToken pagination. createdAfter is inclusive and createdBefore exclusive. Returns 422 (error code 17535) when a sourceId's historical item count exceeds the service scan cap + + [2026-08-11] Version 9.11.0 --------------------------- **Library - Fix** diff --git a/setup.py b/setup.py index c31508371..c131ece07 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.11.0", + version="9.11.1", description="Twilio API client and TwiML generator", author="Twilio", help_center="https://www.twilio.com/help/contact", diff --git a/twilio/__init__.py b/twilio/__init__.py index 2ef30c7eb..0ab1f74eb 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "11", "0") +__version_info__ = ("9", "11", "1") __version__ = ".".join(__version_info__) diff --git a/twilio/rest/content/v1/content/approval_create.py b/twilio/rest/content/v1/content/approval_create.py index 2487ec609..cfb7b88bf 100644 --- a/twilio/rest/content/v1/content/approval_create.py +++ b/twilio/rest/content/v1/content/approval_create.py @@ -27,17 +27,20 @@ class ContentApprovalRequest(object): """ :ivar name: Name of the template. :ivar category: A WhatsApp recognized template category. + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") def to_dict(self): return { "name": self.name, "category": self.category, + "send_ttl_seconds": self.send_ttl_seconds, } """ @@ -47,6 +50,7 @@ def to_dict(self): :ivar status: :ivar rejection_reason: :ivar allow_category_change: + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): @@ -60,6 +64,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): self.allow_category_change: Optional[bool] = payload.get( "allow_category_change" ) + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") self._solution = { "content_sid": content_sid, @@ -81,17 +86,20 @@ class ContentApprovalRequest(object): """ :ivar name: Name of the template. :ivar category: A WhatsApp recognized template category. + :ivar send_ttl_seconds: Time-to-live in seconds for attempting to send a message with this Content """ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") + self.send_ttl_seconds: Optional[int] = payload.get("send_ttl_seconds") def to_dict(self): return { "name": self.name, "category": self.category, + "send_ttl_seconds": self.send_ttl_seconds, } def __init__(self, version: Version, content_sid: str): diff --git a/twilio/rest/insights/v3/__init__.py b/twilio/rest/insights/v3/__init__.py index 293980816..fac7fd5eb 100644 --- a/twilio/rest/insights/v3/__init__.py +++ b/twilio/rest/insights/v3/__init__.py @@ -17,7 +17,6 @@ from twilio.base.domain import Domain from twilio.rest.insights.v3.metadata import MetadataList from twilio.rest.insights.v3.query import QueryList -from twilio.rest.insights.v3.query_job import QueryJobList class V3(Version): @@ -31,7 +30,6 @@ def __init__(self, domain: Domain): super().__init__(domain, "v3") self._metadata: Optional[MetadataList] = None self._query: Optional[QueryList] = None - self._query_jobs: Optional[QueryJobList] = None @property def metadata(self) -> MetadataList: @@ -45,12 +43,6 @@ def query(self) -> QueryList: self._query = QueryList(self) return self._query - @property - def query_jobs(self) -> QueryJobList: - if self._query_jobs is None: - self._query_jobs = QueryJobList(self) - return self._query_jobs - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/insights/v3/query_job.py b/twilio/rest/insights/v3/query_job.py deleted file mode 100644 index 893dce976..000000000 --- a/twilio/rest/insights/v3/query_job.py +++ /dev/null @@ -1,1004 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from __future__ import annotations - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, values -from twilio.base.api_response import ApiResponse -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.token_pagination import TokenPagination - - -class QueryJobInstance(InstanceResource): - - class LongRunningOperationStatus(object): - PENDING = "PENDING" - RUNNING = "RUNNING" - CANCELLED = "CANCELLED" - COMPLETED = "COMPLETED" - FAILED = "FAILED" - - """ - :ivar operation_id: - :ivar status: - :ivar status_url: - :ivar created_at: - :ivar completed_at: When the operation reached a terminal state. - :ivar error: Error details. Present only when status is FAILED. - :ivar result_url: URL to retrieve query results. Present only when status is COMPLETED. Supports pagination via pageSize and pageToken query parameters. - :ivar result_retention_period: ISO 8601 duration for how long results are retained. - """ - - def __init__( - self, - version: Version, - payload: ResponseResource, - operation_id: Optional[str] = None, - ): - super().__init__(version) - - self.operation_id: Optional[str] = payload.get("operationId") - self.status: Optional["QueryJobInstance.LongRunningOperationStatus"] = ( - payload.get("status") - ) - self.status_url: Optional[str] = payload.get("statusUrl") - self.created_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("createdAt") - ) - self.completed_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("completedAt") - ) - self.error: Optional[OperationError] = payload.get("error") - self.result_url: Optional[str] = payload.get("resultUrl") - self.result_retention_period: Optional[str] = payload.get( - "resultRetentionPeriod" - ) - - # Only set _solution if path params are provided (not None) - if operation_id is not None: - self._solution = { - "operation_id": operation_id, - } - - self._context: Optional[QueryJobContext] = None - - @property - def _proxy(self) -> "QueryJobContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: QueryJobContext for this QueryJobInstance - """ - if self._context is None: - self._context = QueryJobContext( - self._version, - operation_id=self._solution["operation_id"], - ) - return self._context - - def fetch(self) -> "QueryJobInstance": - """ - Fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "QueryJobInstance": - """ - Asynchronous coroutine to fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - return await self._proxy.fetch_async() - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the QueryJobInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return self._proxy.fetch_with_http_info() - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the QueryJobInstance with HTTP info - - - :returns: ApiResponse with instance, status code, and headers - """ - return await self._proxy.fetch_with_http_info_async() - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class QueryJobContext(InstanceContext): - - def __init__(self, version: Version, operation_id: str): - """ - Initialize the QueryJobContext - - :param version: Version that contains the resource - :param operation_id: The unique identifier for the async query operation (TTID format). - """ - super().__init__(version) - - # Path Solution - self._solution = { - "operation_id": operation_id, - } - self._uri = "/InsightsDomains/Conversations/QueryJobs/{operation_id}".format( - **self._solution - ) - - def _fetch(self) -> tuple: - """ - Internal helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - return self._version.fetch_with_response_info( - method="GET", uri=self._uri, headers=headers - ) - - def fetch(self) -> QueryJobInstance: - """ - Fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - payload, _, _ = self._fetch() - return QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - - def fetch_with_http_info(self) -> ApiResponse: - """ - Fetch the QueryJobInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch() - instance = QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _fetch_async(self) -> tuple: - """ - Internal async helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - - headers = values.of({}) - - headers["Accept"] = "application/json" - - return await self._version.fetch_with_response_info_async( - method="GET", uri=self._uri, headers=headers - ) - - async def fetch_async(self) -> QueryJobInstance: - """ - Asynchronous coroutine to fetch the QueryJobInstance - - - :returns: The fetched QueryJobInstance - """ - payload, _, _ = await self._fetch_async() - return QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - - async def fetch_with_http_info_async(self) -> ApiResponse: - """ - Asynchronous coroutine to fetch the QueryJobInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async() - instance = QueryJobInstance( - self._version, - payload, - operation_id=self._solution["operation_id"], - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class QueryJobPage(TokenPagination): - - def get_instance(self, payload: Dict[str, Any]) -> QueryJobInstance: - """ - Build an instance of QueryJobInstance - - :param payload: Payload response from the API - """ - - return QueryJobInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class QueryJobList(ListResource): - - class InsightsQueryRequest(object): - """ - :ivar domain: The business domain to execute the query against - :ivar query: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.domain: Optional[str] = payload.get("domain") - self.query: Optional[QueryList.QueryDefinition] = payload.get("query") - - def to_dict(self): - return { - "domain": self.domain, - "query": self.query.to_dict() if self.query is not None else None, - } - - class OperationError(object): - """ - :ivar code: Twilio-specific error code - :ivar message: A human readable error message - :ivar http_status_code: HTTP status code that would have been returned for a synchronous failure - :ivar detail: Additional context about the failure - """ - - def __init__(self, payload: Dict[str, Any]): - - self.code: Optional[int] = payload.get("code") - self.message: Optional[str] = payload.get("message") - self.http_status_code: Optional[int] = payload.get("httpStatusCode") - self.detail: Optional[str] = payload.get("detail") - - def to_dict(self): - return { - "code": self.code, - "message": self.message, - "httpStatusCode": self.http_status_code, - "detail": self.detail, - } - - class QueryDefinition(object): - """ - :ivar measures: Array of measures to retrieve, representing quantitative values or metrics to be calculated - :ivar dimensions: Array of dimensions to retrieve, representing categorical attributes for grouping and organizing data - :ivar filters: Nested filter conditions. Always use `op` and `expressions`. - :ivar order_by: Specifications for sorting the query results by specific fields in ascending or descending order - """ - - def __init__(self, payload: Dict[str, Any]): - - self.measures: Optional[List[str]] = payload.get("measures") - self.dimensions: Optional[List[str]] = payload.get("dimensions") - self.filters: Optional[List[QueryList.QueryDefinitionFilters]] = ( - payload.get("filters") - ) - self.order_by: Optional[List[QueryList.QueryDefinitionOrderBy]] = ( - payload.get("orderBy") - ) - - def to_dict(self): - return { - "measures": self.measures, - "dimensions": self.dimensions, - "filters": ( - [filters.to_dict() for filters in self.filters] - if self.filters is not None - else None - ), - "orderBy": ( - [order_by.to_dict() for order_by in self.order_by] - if self.order_by is not None - else None - ), - } - - class QueryDefinitionFilters(object): - """ - :ivar op: - :ivar expressions: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.op: Optional["QueryInstance.str"] = payload.get("op") - self.expressions: Optional[ - List[QueryList.QueryDefinitionFiltersExpressions] - ] = payload.get("expressions") - - def to_dict(self): - return { - "op": self.op, - "expressions": ( - [expressions.to_dict() for expressions in self.expressions] - if self.expressions is not None - else None - ), - } - - class QueryDefinitionFiltersExpressions(object): - """ - :ivar op: - :ivar field: - :ivar values: - """ - - def __init__(self, payload: Dict[str, Any]): - - self.op: Optional["QueryInstance.str"] = payload.get("op") - self.field: Optional[str] = payload.get("field") - self.values: Optional[List[str]] = payload.get("values") - - def to_dict(self): - return { - "op": self.op, - "field": self.field, - "values": self.values, - } - - class QueryDefinitionOrderBy(object): - """ - :ivar field: Dimension or measure to order by - :ivar direction: Sort order direction, ascending or descending - """ - - def __init__(self, payload: Dict[str, Any]): - - self.field: Optional[str] = payload.get("field") - self.direction: Optional["QueryInstance.str"] = payload.get("direction") - - def to_dict(self): - return { - "field": self.field, - "direction": self.direction, - } - - def __init__(self, version: Version): - """ - Initialize the QueryJobList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/InsightsDomains/Conversations/QueryJobs" - - def _create( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_query_request.to_dict() - - headers = values.of( - { - "Idempotency-Key": idempotency_key, - "Content-Type": "application/x-www-form-urlencoded", - } - ) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, data=data, headers=headers - ) - - def create( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> QueryJobInstance: - """ - Create the QueryJobInstance - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: The created QueryJobInstance - """ - payload, _, _ = self._create( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - return QueryJobInstance(self._version, payload) - - def create_with_http_info( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Create the QueryJobInstance and return response metadata - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - instance = QueryJobInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - data = insights_query_request.to_dict() - - headers = values.of( - { - "Idempotency-Key": idempotency_key, - "Content-Type": "application/x-www-form-urlencoded", - } - ) - - headers["Content-Type"] = "application/json" - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - async def create_async( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> QueryJobInstance: - """ - Asynchronously create the QueryJobInstance - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: The created QueryJobInstance - """ - payload, _, _ = await self._create_async( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - return QueryJobInstance(self._version, payload) - - async def create_with_http_info_async( - self, - insights_query_request: InsightsQueryRequest, - idempotency_key: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronously create the QueryJobInstance and return response metadata - - :param insights_query_request: - :param idempotency_key: Client-generated UUIDv7 key to ensure idempotent behavior. Submitting the same key for identical requests returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async( - insights_query_request=insights_query_request, - idempotency_key=idempotency_key, - ) - instance = QueryJobInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def stream( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[QueryJobInstance]: - """ - Streams QueryJobInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[QueryJobInstance]: - """ - Asynchronously streams QueryJobInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def stream_with_http_info( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Streams QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: tuple of (generator, status_code, headers) where generator yields instances - """ - limits = self._version.read_limits(limit, page_size) - page_response = self.page_with_http_info( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - generator = self._version.stream(page_response.data, limits["limit"]) - return (generator, page_response.status_code, page_response.headers) - - async def stream_with_http_info_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> tuple: - """ - Asynchronously streams QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: tuple of (generator, status_code, headers) where generator yields instances - """ - limits = self._version.read_limits(limit, page_size) - page_response = await self.page_with_http_info_async( - page_token=page_token, status=status, page_size=limits["page_size"] - ) - - generator = self._version.stream_async(page_response.data, limits["limit"]) - return (generator, page_response.status_code, page_response.headers) - - def list( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryJobInstance]: - """ - Lists QueryJobInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - - return list( - self.stream( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryJobInstance]: - """ - Asynchronously lists QueryJobInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - - return [ - record - async for record in await self.stream_async( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - ] - - def list_with_http_info( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Lists QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: ApiResponse with list of instances, status code, and headers - """ - generator, status_code, headers = self.stream_with_http_info( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - items = list(generator) - return ApiResponse(data=items, status_code=status_code, headers=headers) - - async def list_with_http_info_async( - self, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ApiResponse: - """ - Asynchronously lists QueryJobInstance and returns headers from first page - - - :param str page_token: Token for pagination - :param LongRunningOperationStatus status: Filter by operation status. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: ApiResponse with list of instances, status code, and headers - """ - generator, status_code, headers = await self.stream_with_http_info_async( - page_token=page_token, - status=status, - limit=limit, - page_size=page_size, - ) - items = [record async for record in generator] - return ApiResponse(data=items, status_code=status_code, headers=headers) - - def page( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - ) -> QueryJobPage: - """ - Retrieve a single page of QueryJobInstance records from the API. - Request is executed immediately - - :param page_size: The maximum number of resources to return - :param page_token: Token for pagination - :param status: Filter by operation status. - :returns: Page of QueryJobInstance - """ - data = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - "status": status, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response = self._version.page( - method="GET", uri=self._uri, params=data, headers=headers - ) - return QueryJobPage(self._version, response, uri=self._uri, params=data) - - async def page_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - status: Union[LongRunningOperationStatus, object] = values.unset, - ) -> QueryJobPage: - """ - Asynchronously retrieve a single page of QueryJobInstance records from the API. - Request is executed immediately - - :param page_size: The maximum number of resources to return - :param page_token: Token for pagination - :param status: Filter by operation status. - :returns: Page of QueryJobInstance - """ - data = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - "status": status, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data, headers=headers - ) - return QueryJobPage(self._version, response, uri=self._uri, params=data) - - def page_with_http_info( - self, - status: Union[LongRunningOperationStatus, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ApiResponse: - """ - Retrieve a single page with response metadata - - - :param page_token: Token for pagination - :param status: Filter by operation status. - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: ApiResponse with QueryJobPage, status code, and headers - """ - data = values.of( - { - "pageToken": page_token, - "status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response, status_code, response_headers = self._version.page_with_response_info( - method="GET", uri=self._uri, params=data, headers=headers - ) - page = QueryJobPage(self._version, response, uri=self._uri) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - async def page_with_http_info_async( - self, - status: Union[LongRunningOperationStatus, object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronously retrieve a single page with response metadata - - - :param page_token: Token for pagination - :param status: Filter by operation status. - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: ApiResponse with QueryJobPage, status code, and headers - """ - data = values.of( - { - "pageToken": page_token, - "status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - response, status_code, response_headers = ( - await self._version.page_with_response_info_async( - method="GET", uri=self._uri, params=data, headers=headers - ) - ) - page = QueryJobPage(self._version, response) - return ApiResponse(data=page, status_code=status_code, headers=response_headers) - - def get_page(self, target_url: str) -> QueryJobPage: - """ - Retrieve a specific page of QueryJobInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryJobInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return QueryJobPage(self._version, response) - - async def get_page_async(self, target_url: str) -> QueryJobPage: - """ - Asynchronously retrieve a specific page of QueryJobInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryJobInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return QueryJobPage(self._version, response) - - def get(self, operation_id: str) -> QueryJobContext: - """ - Constructs a QueryJobContext - - :param operation_id: The unique identifier for the async query operation (TTID format). - """ - return QueryJobContext(self._version, operation_id=operation_id) - - def __call__(self, operation_id: str) -> QueryJobContext: - """ - Constructs a QueryJobContext - - :param operation_id: The unique identifier for the async query operation (TTID format). - """ - return QueryJobContext(self._version, operation_id=operation_id) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/insights/v3/result.py b/twilio/rest/insights/v3/result.py deleted file mode 100644 index 239c7208d..000000000 --- a/twilio/rest/insights/v3/result.py +++ /dev/null @@ -1,208 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Insights - Insights Domain V3 API. Includes synchronous Query, Metadata, and Async Query (long-running operation) endpoints. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from __future__ import annotations - -from typing import Any, Dict, List, Optional, Union -from twilio.base import values -from twilio.base.api_response import ApiResponse - -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class ResultInstance(InstanceResource): - """ - :ivar domain: Indicates the business domain the query was executed against - :ivar items: Array of result objects containing the query results. Each object contains properties matching the requested measures and dimensions. - :ivar meta: - """ - - def __init__(self, version: Version, payload: Dict[str, Any], operation_id: str): - super().__init__(version) - - self.domain: Optional[str] = payload.get("domain") - self.items: Optional[List[Dict[str, object]]] = payload.get("items") - self.meta: Optional[str] = payload.get("meta") - - # Only set _solution if path params are provided (not None) - if operation_id is not None: - self._solution = { - "operation_id": operation_id, - } - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class ResultList(ListResource): - - def __init__(self, version: Version, operation_id: str): - """ - Initialize the ResultList - - :param version: Version that contains the resource - :param operation_id: The unique identifier for the async query operation. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "operation_id": operation_id, - } - self._uri = ( - "/InsightsDomains/Conversations/QueryJobs/{operation_id}/Results".format( - **self._solution - ) - ) - - def _fetch( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - params = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - } - ) - - return self._version.fetch_with_response_info( - method="GET", uri=self._uri, headers=headers, params=params - ) - - def fetch( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ResultInstance: - """ - Fetch the ResultInstance - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: The fetched ResultInstance - """ - payload, _, _ = self._fetch(page_size=page_size, page_token=page_token) - return ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - - def fetch_with_http_info( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Fetch the ResultInstance and return response metadata - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._fetch( - page_size=page_size, page_token=page_token - ) - instance = ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _fetch_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> tuple: - """ - Internal async helper for fetch operation - - Returns: - tuple: (payload, status_code, headers) - """ - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - params = values.of( - { - "pageSize": page_size, - "pageToken": page_token, - } - ) - - return await self._version.fetch_with_response_info_async( - method="GET", uri=self._uri, headers=headers, params=params - ) - - async def fetch_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ResultInstance: - """ - Asynchronously fetch the ResultInstance - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: The fetched ResultInstance - """ - payload, _, _ = await self._fetch_async( - page_size=page_size, page_token=page_token - ) - return ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - - async def fetch_with_http_info_async( - self, - page_size: Union[int, object] = values.unset, - page_token: Union[str, object] = values.unset, - ) -> ApiResponse: - """ - Asynchronously fetch the ResultInstance and return response metadata - - :param page_size: The maximum number of resources to return:param page_token: Token for pagination - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._fetch_async( - page_size=page_size, page_token=page_token - ) - instance = ResultInstance( - self._version, payload, operation_id=self._solution["operation_id"] - ) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/knowledge/v2/knowledge.py b/twilio/rest/knowledge/v2/knowledge.py index dc40d54a9..d9ec47b0e 100644 --- a/twilio/rest/knowledge/v2/knowledge.py +++ b/twilio/rest/knowledge/v2/knowledge.py @@ -641,6 +641,52 @@ def to_dict(self): "source": self.source.to_dict() if self.source is not None else None, } + class KnowledgeErrorGroup(object): + """ + :ivar title: The error type or reason (e.g., \"404 Not Found\", \"500 Internal Server Error\"). + :ivar instances: Array of error instances for this error title. Required when an error group is present. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.instances: Optional[List[KnowledgeList.KnowledgeErrorInstance]] = ( + payload.get("instances") + ) + + def to_dict(self): + return { + "title": self.title, + "instances": ( + [instances.to_dict() for instances in self.instances] + if self.instances is not None + else None + ), + } + + class KnowledgeErrorInstance(object): + """ + :ivar type: A URI reference identifying the problem type, resolving to human-readable documentation (e.g., https://www.twilio.com/docs/api/errors/420018). + :ivar code: Twilio-specific numeric error code for programmatic handling. + :ivar instance: The specific URL or resource that caused the error. + :ivar detail: Detailed explanation of the error. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional[str] = payload.get("type") + self.code: Optional[int] = payload.get("code") + self.instance: Optional[str] = payload.get("instance") + self.detail: Optional[str] = payload.get("detail") + + def to_dict(self): + return { + "type": self.type, + "code": self.code, + "instance": self.instance, + "detail": self.detail, + } + class KnowledgeSourceTypes(object): """ :ivar type: Raw text knowledge sources @@ -648,6 +694,7 @@ class KnowledgeSourceTypes(object): :ivar url: The URL to crawl for web content :ivar crawl_depth: The maximum depth to crawl from the source URL :ivar crawl_period: Frequency of re-crawling the website for updated content + :ivar errors: Processing errors encountered during web crawling, grouped by title. Array of error groups, where each group has a title and list of error instances. Only present when crawl errors occurred. :ivar file_name: Name of the file to be uploaded :ivar file_size: Expected size of the file in bytes :ivar mime_type: @@ -664,6 +711,9 @@ def __init__(self, payload: Dict[str, Any]): self.crawl_period: Optional["KnowledgeInstance.str"] = payload.get( "crawlPeriod" ) + self.errors: Optional[List[KnowledgeList.KnowledgeErrorGroup]] = ( + payload.get("errors") + ) self.file_name: Optional[str] = payload.get("fileName") self.file_size: Optional[int] = payload.get("fileSize") self.mime_type: Optional["KnowledgeInstance.SupportedFileMimeType"] = ( @@ -679,6 +729,11 @@ def to_dict(self): "url": self.url, "crawlDepth": self.crawl_depth, "crawlPeriod": self.crawl_period, + "errors": ( + [errors.to_dict() for errors in self.errors] + if self.errors is not None + else None + ), "fileName": self.file_name, "fileSize": self.file_size, "mimeType": self.mime_type, diff --git a/twilio/rest/memory/v1/data_mapping.py b/twilio/rest/memory/v1/data_mapping.py index 8cefd6789..630a89841 100644 --- a/twilio/rest/memory/v1/data_mapping.py +++ b/twilio/rest/memory/v1/data_mapping.py @@ -30,6 +30,9 @@ class DataMappingInstance(InstanceResource): class DataMappingType(object): CSV = "CSV" DATASET = "DATASET" + INGRESS = "INGRESS" + DATASET_CLOUDAPP = "DATASET_CLOUDAPP" + DATASET_WAREHOUSE = "DATASET_WAREHOUSE" """ :ivar message: @@ -652,7 +655,7 @@ def to_dict(self): class DataMappingFromTypes(object): """ :ivar type: The source data type, which determines the source of the data and the required configuration parameters. - :ivar columns: The list of CSV column names that serve as the source fields. + :ivar columns: The list of ingress column names that serve as the source fields. :ivar dataset_id: The unique identifier of the TDI dataset to connect. """ diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index a3f3cc084..59dd3d522 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -34,6 +34,10 @@ from twilio.rest.numbers.v1.signing_request_configuration import ( SigningRequestConfigurationList, ) +from twilio.rest.numbers.v1.sms_verification import SmsVerificationList +from twilio.rest.numbers.v1.sms_verification_check import SmsVerificationCheckList +from twilio.rest.numbers.v1.voice_verification import VoiceVerificationList +from twilio.rest.numbers.v1.voice_verification_check import VoiceVerificationCheckList from twilio.rest.numbers.v1.webhook import WebhookList @@ -64,6 +68,10 @@ def __init__(self, domain: Domain): self._signing_request_configurations: Optional[ SigningRequestConfigurationList ] = None + self._sms_verifications: Optional[SmsVerificationList] = None + self._sms_verification_checks: Optional[SmsVerificationCheckList] = None + self._voice_verifications: Optional[VoiceVerificationList] = None + self._voice_verification_checks: Optional[VoiceVerificationCheckList] = None self._webhook: Optional[WebhookList] = None @property @@ -144,6 +152,30 @@ def signing_request_configurations(self) -> SigningRequestConfigurationList: self._signing_request_configurations = SigningRequestConfigurationList(self) return self._signing_request_configurations + @property + def sms_verifications(self) -> SmsVerificationList: + if self._sms_verifications is None: + self._sms_verifications = SmsVerificationList(self) + return self._sms_verifications + + @property + def sms_verification_checks(self) -> SmsVerificationCheckList: + if self._sms_verification_checks is None: + self._sms_verification_checks = SmsVerificationCheckList(self) + return self._sms_verification_checks + + @property + def voice_verifications(self) -> VoiceVerificationList: + if self._voice_verifications is None: + self._voice_verifications = VoiceVerificationList(self) + return self._voice_verifications + + @property + def voice_verification_checks(self) -> VoiceVerificationCheckList: + if self._voice_verification_checks is None: + self._voice_verification_checks = VoiceVerificationCheckList(self) + return self._voice_verification_checks + @property def webhook(self) -> WebhookList: if self._webhook is None: diff --git a/twilio/rest/numbers/v1/sms_verification.py b/twilio/rest/numbers/v1/sms_verification.py new file mode 100644 index 000000000..71d0d2215 --- /dev/null +++ b/twilio/rest/numbers/v1/sms_verification.py @@ -0,0 +1,141 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class SmsVerificationInstance(InstanceResource): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_sid: The unique SID of this verification resource. + :ivar send_code_attempts: An array of verification attempt objects. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.verification_sid: Optional[str] = payload.get("verificationSid") + self.send_code_attempts: Optional[List[str]] = payload.get("sendCodeAttempts") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SmsVerificationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SmsVerificationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/SmsVerifications" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> SmsVerificationInstance: + """ + Create the SmsVerificationInstance + + + :returns: The created SmsVerificationInstance + """ + payload, _, _ = self._create() + return SmsVerificationInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the SmsVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = SmsVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> SmsVerificationInstance: + """ + Asynchronously create the SmsVerificationInstance + + + :returns: The created SmsVerificationInstance + """ + payload, _, _ = await self._create_async() + return SmsVerificationInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the SmsVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = SmsVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/sms_verification_check.py b/twilio/rest/numbers/v1/sms_verification_check.py new file mode 100644 index 000000000..f57035319 --- /dev/null +++ b/twilio/rest/numbers/v1/sms_verification_check.py @@ -0,0 +1,143 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class SmsVerificationCheckInstance(InstanceResource): + """ + :ivar to: The phone number that was verified in E.164 format. + :ivar verification_sid: The unique SID of this verification resource. + :ivar status: The status of the verification (pending, approved, canceled). + :ivar caller_id_sid: The Caller ID SID created upon successful verification. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.verification_sid: Optional[str] = payload.get("verificationSid") + self.status: Optional[str] = payload.get("status") + self.caller_id_sid: Optional[str] = payload.get("callerIdSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SmsVerificationCheckList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SmsVerificationCheckList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/SmsVerificationChecks" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> SmsVerificationCheckInstance: + """ + Create the SmsVerificationCheckInstance + + + :returns: The created SmsVerificationCheckInstance + """ + payload, _, _ = self._create() + return SmsVerificationCheckInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the SmsVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = SmsVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> SmsVerificationCheckInstance: + """ + Asynchronously create the SmsVerificationCheckInstance + + + :returns: The created SmsVerificationCheckInstance + """ + payload, _, _ = await self._create_async() + return SmsVerificationCheckInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the SmsVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = SmsVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/voice_verification.py b/twilio/rest/numbers/v1/voice_verification.py new file mode 100644 index 000000000..5e41647d7 --- /dev/null +++ b/twilio/rest/numbers/v1/voice_verification.py @@ -0,0 +1,145 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class VoiceVerificationInstance(InstanceResource): + """ + :ivar account_sid: The Account SID that owns this verification. + :ivar phone_number: The phone number being verified in E.164 format. + :ivar friendly_name: A human-readable name for this caller ID. + :ivar validation_code: The 6-digit validation code to be entered during the call. + :ivar call_sid: The Call SID for the verification call. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("accountSid") + self.phone_number: Optional[str] = payload.get("phoneNumber") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.validation_code: Optional[str] = payload.get("validationCode") + self.call_sid: Optional[str] = payload.get("callSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class VoiceVerificationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the VoiceVerificationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/VoiceVerifications" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> VoiceVerificationInstance: + """ + Create the VoiceVerificationInstance + + + :returns: The created VoiceVerificationInstance + """ + payload, _, _ = self._create() + return VoiceVerificationInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the VoiceVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = VoiceVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> VoiceVerificationInstance: + """ + Asynchronously create the VoiceVerificationInstance + + + :returns: The created VoiceVerificationInstance + """ + payload, _, _ = await self._create_async() + return VoiceVerificationInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the VoiceVerificationInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = VoiceVerificationInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/voice_verification_check.py b/twilio/rest/numbers/v1/voice_verification_check.py new file mode 100644 index 000000000..28d201e55 --- /dev/null +++ b/twilio/rest/numbers/v1/voice_verification_check.py @@ -0,0 +1,139 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class VoiceVerificationCheckInstance(InstanceResource): + """ + :ivar to: The phone number that was verified in E.164 format. + :ivar caller_id_sid: The Caller ID SID created upon successful verification. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.to: Optional[str] = payload.get("to") + self.caller_id_sid: Optional[str] = payload.get("callerIdSid") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class VoiceVerificationCheckList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the VoiceVerificationCheckList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds/VoiceVerificationChecks" + + def _create(self) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, headers=headers + ) + + def create(self) -> VoiceVerificationCheckInstance: + """ + Create the VoiceVerificationCheckInstance + + + :returns: The created VoiceVerificationCheckInstance + """ + payload, _, _ = self._create() + return VoiceVerificationCheckInstance(self._version, payload) + + def create_with_http_info(self) -> ApiResponse: + """ + Create the VoiceVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create() + instance = VoiceVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, headers=headers + ) + + async def create_async(self) -> VoiceVerificationCheckInstance: + """ + Asynchronously create the VoiceVerificationCheckInstance + + + :returns: The created VoiceVerificationCheckInstance + """ + payload, _, _ = await self._create_async() + return VoiceVerificationCheckInstance(self._version, payload) + + async def create_with_http_info_async(self) -> ApiResponse: + """ + Asynchronously create the VoiceVerificationCheckInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async() + instance = VoiceVerificationCheckInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v2/__init__.py b/twilio/rest/numbers/v2/__init__.py index e4f306025..908681290 100644 --- a/twilio/rest/numbers/v2/__init__.py +++ b/twilio/rest/numbers/v2/__init__.py @@ -19,6 +19,7 @@ from twilio.rest.numbers.v2.authorization_document import AuthorizationDocumentList from twilio.rest.numbers.v2.bulk_hosted_number_order import BulkHostedNumberOrderList from twilio.rest.numbers.v2.bundle_clone import BundleCloneList +from twilio.rest.numbers.v2.caller_id import CallerIdList from twilio.rest.numbers.v2.hosted_number_order import HostedNumberOrderList from twilio.rest.numbers.v2.regulatory_compliance import RegulatoryComplianceList @@ -36,6 +37,7 @@ def __init__(self, domain: Domain): self._authorization_documents: Optional[AuthorizationDocumentList] = None self._bulk_hosted_number_orders: Optional[BulkHostedNumberOrderList] = None self._bundle_clone: Optional[BundleCloneList] = None + self._caller_ids: Optional[CallerIdList] = None self._hosted_number_orders: Optional[HostedNumberOrderList] = None self._regulatory_compliance: Optional[RegulatoryComplianceList] = None @@ -63,6 +65,12 @@ def bundle_clone(self) -> BundleCloneList: self._bundle_clone = BundleCloneList(self) return self._bundle_clone + @property + def caller_ids(self) -> CallerIdList: + if self._caller_ids is None: + self._caller_ids = CallerIdList(self) + return self._caller_ids + @property def hosted_number_orders(self) -> HostedNumberOrderList: if self._hosted_number_orders is None: diff --git a/twilio/rest/numbers/v2/caller_id.py b/twilio/rest/numbers/v2/caller_id.py new file mode 100644 index 000000000..6ac3cda75 --- /dev/null +++ b/twilio/rest/numbers/v2/caller_id.py @@ -0,0 +1,757 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.api_response import ApiResponse +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class CallerIdInstance(InstanceResource): + """ + :ivar sid: The unique SID of this Caller ID resource. + :ivar account_sid: The Account SID that owns this Caller ID. + :ivar phone_number: The phone number in E.164 format. + :ivar friendly_name: A human-readable name for this caller ID. + :ivar date_created: The date this resource was created. + :ivar date_updated: The date this resource was last updated. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + caller_id_sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.account_sid: Optional[str] = payload.get("accountSid") + self.phone_number: Optional[str] = payload.get("phoneNumber") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateCreated") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateUpdated") + ) + + self._solution = { + "caller_id_sid": caller_id_sid or self.caller_id_sid, + } + + self._context: Optional[CallerIdContext] = None + + @property + def _proxy(self) -> "CallerIdContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: CallerIdContext for this CallerIdInstance + """ + if self._context is None: + self._context = CallerIdContext( + self._version, + caller_id_sid=self._solution["caller_id_sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the CallerIdInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the CallerIdInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the CallerIdInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the CallerIdInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def update(self) -> "CallerIdInstance": + """ + Update the CallerIdInstance + + + :returns: The updated CallerIdInstance + """ + return self._proxy.update() + + async def update_async(self) -> "CallerIdInstance": + """ + Asynchronous coroutine to update the CallerIdInstance + + + :returns: The updated CallerIdInstance + """ + return await self._proxy.update_async() + + def update_with_http_info(self) -> ApiResponse: + """ + Update the CallerIdInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info() + + async def update_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to update the CallerIdInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async() + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class CallerIdContext(InstanceContext): + + def __init__(self, version: Version, caller_id_sid: str): + """ + Initialize the CallerIdContext + + :param version: Version that contains the resource + :param caller_id_sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "caller_id_sid": caller_id_sid, + } + self._uri = "/CallerIds/{caller_id_sid}".format(**self._solution) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the CallerIdInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the CallerIdInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the CallerIdInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the CallerIdInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + def _update(self) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def update(self) -> CallerIdInstance: + """ + Update the CallerIdInstance + + + :returns: The updated CallerIdInstance + """ + payload, _, _ = self._update() + return CallerIdInstance( + self._version, payload, caller_id_sid=self._solution["caller_id_sid"] + ) + + def update_with_http_info(self) -> ApiResponse: + """ + Update the CallerIdInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update() + instance = CallerIdInstance( + self._version, payload, caller_id_sid=self._solution["caller_id_sid"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async(self) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def update_async(self) -> CallerIdInstance: + """ + Asynchronous coroutine to update the CallerIdInstance + + + :returns: The updated CallerIdInstance + """ + payload, _, _ = await self._update_async() + return CallerIdInstance( + self._version, payload, caller_id_sid=self._solution["caller_id_sid"] + ) + + async def update_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to update the CallerIdInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async() + instance = CallerIdInstance( + self._version, payload, caller_id_sid=self._solution["caller_id_sid"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class CallerIdPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> CallerIdInstance: + """ + Build an instance of CallerIdInstance + + :param payload: Payload response from the API + """ + + return CallerIdInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class CallerIdList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the CallerIdList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/CallerIds" + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[CallerIdInstance]: + """ + Streams CallerIdInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[CallerIdInstance]: + """ + Asynchronously streams CallerIdInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams CallerIdInstance and returns headers from first page + + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info(page_size=limits["page_size"]) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams CallerIdInstance and returns headers from first page + + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + page_size=limits["page_size"] + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[CallerIdInstance]: + """ + Lists CallerIdInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[CallerIdInstance]: + """ + Asynchronously lists CallerIdInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists CallerIdInstance and returns headers from first page + + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists CallerIdInstance and returns headers from first page + + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> CallerIdPage: + """ + Retrieve a single page of CallerIdInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of CallerIdInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return CallerIdPage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> CallerIdPage: + """ + Asynchronously retrieve a single page of CallerIdInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of CallerIdInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return CallerIdPage(self._version, response) + + def page_with_http_info( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: ApiResponse with CallerIdPage, status code, and headers + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = CallerIdPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: ApiResponse with CallerIdPage, status code, and headers + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = CallerIdPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> CallerIdPage: + """ + Retrieve a specific page of CallerIdInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of CallerIdInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return CallerIdPage(self._version, response) + + async def get_page_async(self, target_url: str) -> CallerIdPage: + """ + Asynchronously retrieve a specific page of CallerIdInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of CallerIdInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return CallerIdPage(self._version, response) + + def get(self, caller_id_sid: str) -> CallerIdContext: + """ + Constructs a CallerIdContext + + :param caller_id_sid: + """ + return CallerIdContext(self._version, caller_id_sid=caller_id_sid) + + def __call__(self, caller_id_sid: str) -> CallerIdContext: + """ + Constructs a CallerIdContext + + :param caller_id_sid: + """ + return CallerIdContext(self._version, caller_id_sid=caller_id_sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/oauth/v1/oauth_authorization_server.py b/twilio/rest/oauth/v2/oauth_authorization_server.py similarity index 96% rename from twilio/rest/oauth/v1/oauth_authorization_server.py rename to twilio/rest/oauth/v2/oauth_authorization_server.py index 4fcdd357c..758831a4b 100644 --- a/twilio/rest/oauth/v1/oauth_authorization_server.py +++ b/twilio/rest/oauth/v2/oauth_authorization_server.py @@ -4,8 +4,8 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Oauth - This is the public Twilio REST API. + User OAuth API + User OAuth API NOTE: This class is auto generated by OpenAPI Generator. https://openapi-generator.tech @@ -60,7 +60,7 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" class OauthAuthorizationServerList(ListResource): @@ -154,4 +154,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return ""