Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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 Optional
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest.preview.understand.assistant import AssistantList
|
||||
|
||||
|
||||
class Understand(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the Understand version of Preview
|
||||
|
||||
:param domain: The Twilio.preview domain
|
||||
"""
|
||||
super().__init__(domain, "understand")
|
||||
self._assistants: Optional[AssistantList] = None
|
||||
|
||||
@property
|
||||
def assistants(self) -> AssistantList:
|
||||
if self._assistants is None:
|
||||
self._assistants = AssistantList(self)
|
||||
return self._assistants
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand>"
|
||||
BIN
Binary file not shown.
+887
@@ -0,0 +1,887 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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, serialize, values
|
||||
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
|
||||
from twilio.rest.preview.understand.assistant.assistant_fallback_actions import (
|
||||
AssistantFallbackActionsList,
|
||||
)
|
||||
from twilio.rest.preview.understand.assistant.assistant_initiation_actions import (
|
||||
AssistantInitiationActionsList,
|
||||
)
|
||||
from twilio.rest.preview.understand.assistant.dialogue import DialogueList
|
||||
from twilio.rest.preview.understand.assistant.field_type import FieldTypeList
|
||||
from twilio.rest.preview.understand.assistant.model_build import ModelBuildList
|
||||
from twilio.rest.preview.understand.assistant.query import QueryList
|
||||
from twilio.rest.preview.understand.assistant.style_sheet import StyleSheetList
|
||||
from twilio.rest.preview.understand.assistant.task import TaskList
|
||||
|
||||
|
||||
class AssistantInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Assistant.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:ivar latest_model_build_sid: The unique ID (Sid) of the latest model build. Null if no model has been built.
|
||||
:ivar links:
|
||||
:ivar log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. You can use the unique name in the URL path. Unique up to 64 characters long.
|
||||
:ivar url:
|
||||
:ivar callback_url: A user-provided URL to send event callbacks to.
|
||||
:ivar callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.latest_model_build_sid: Optional[str] = payload.get(
|
||||
"latest_model_build_sid"
|
||||
)
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.log_queries: Optional[bool] = payload.get("log_queries")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.callback_url: Optional[str] = payload.get("callback_url")
|
||||
self.callback_events: Optional[str] = payload.get("callback_events")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AssistantContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AssistantContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AssistantContext for this AssistantInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AssistantContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AssistantInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AssistantInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "AssistantInstance":
|
||||
"""
|
||||
Fetch the AssistantInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AssistantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssistantInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
log_queries: Union[bool, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
callback_events: Union[str, object] = values.unset,
|
||||
fallback_actions: Union[object, object] = values.unset,
|
||||
initiation_actions: Union[object, object] = values.unset,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
) -> "AssistantInstance":
|
||||
"""
|
||||
Update the AssistantInstance
|
||||
|
||||
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param callback_url: A user-provided URL to send event callbacks to.
|
||||
:param callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
|
||||
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
|
||||
:param style_sheet: The JSON object that holds the style sheet for the assistant
|
||||
|
||||
:returns: The updated AssistantInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
log_queries=log_queries,
|
||||
unique_name=unique_name,
|
||||
callback_url=callback_url,
|
||||
callback_events=callback_events,
|
||||
fallback_actions=fallback_actions,
|
||||
initiation_actions=initiation_actions,
|
||||
style_sheet=style_sheet,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
log_queries: Union[bool, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
callback_events: Union[str, object] = values.unset,
|
||||
fallback_actions: Union[object, object] = values.unset,
|
||||
initiation_actions: Union[object, object] = values.unset,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
) -> "AssistantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantInstance
|
||||
|
||||
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param callback_url: A user-provided URL to send event callbacks to.
|
||||
:param callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
|
||||
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
|
||||
:param style_sheet: The JSON object that holds the style sheet for the assistant
|
||||
|
||||
:returns: The updated AssistantInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
log_queries=log_queries,
|
||||
unique_name=unique_name,
|
||||
callback_url=callback_url,
|
||||
callback_events=callback_events,
|
||||
fallback_actions=fallback_actions,
|
||||
initiation_actions=initiation_actions,
|
||||
style_sheet=style_sheet,
|
||||
)
|
||||
|
||||
@property
|
||||
def assistant_fallback_actions(self) -> AssistantFallbackActionsList:
|
||||
"""
|
||||
Access the assistant_fallback_actions
|
||||
"""
|
||||
return self._proxy.assistant_fallback_actions
|
||||
|
||||
@property
|
||||
def assistant_initiation_actions(self) -> AssistantInitiationActionsList:
|
||||
"""
|
||||
Access the assistant_initiation_actions
|
||||
"""
|
||||
return self._proxy.assistant_initiation_actions
|
||||
|
||||
@property
|
||||
def dialogues(self) -> DialogueList:
|
||||
"""
|
||||
Access the dialogues
|
||||
"""
|
||||
return self._proxy.dialogues
|
||||
|
||||
@property
|
||||
def field_types(self) -> FieldTypeList:
|
||||
"""
|
||||
Access the field_types
|
||||
"""
|
||||
return self._proxy.field_types
|
||||
|
||||
@property
|
||||
def model_builds(self) -> ModelBuildList:
|
||||
"""
|
||||
Access the model_builds
|
||||
"""
|
||||
return self._proxy.model_builds
|
||||
|
||||
@property
|
||||
def queries(self) -> QueryList:
|
||||
"""
|
||||
Access the queries
|
||||
"""
|
||||
return self._proxy.queries
|
||||
|
||||
@property
|
||||
def style_sheet(self) -> StyleSheetList:
|
||||
"""
|
||||
Access the style_sheet
|
||||
"""
|
||||
return self._proxy.style_sheet
|
||||
|
||||
@property
|
||||
def tasks(self) -> TaskList:
|
||||
"""
|
||||
Access the tasks
|
||||
"""
|
||||
return self._proxy.tasks
|
||||
|
||||
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 "<Twilio.Preview.Understand.AssistantInstance {}>".format(context)
|
||||
|
||||
|
||||
class AssistantContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the AssistantContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{sid}".format(**self._solution)
|
||||
|
||||
self._assistant_fallback_actions: Optional[AssistantFallbackActionsList] = None
|
||||
self._assistant_initiation_actions: Optional[
|
||||
AssistantInitiationActionsList
|
||||
] = None
|
||||
self._dialogues: Optional[DialogueList] = None
|
||||
self._field_types: Optional[FieldTypeList] = None
|
||||
self._model_builds: Optional[ModelBuildList] = None
|
||||
self._queries: Optional[QueryList] = None
|
||||
self._style_sheet: Optional[StyleSheetList] = None
|
||||
self._tasks: Optional[TaskList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the AssistantInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the AssistantInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> AssistantInstance:
|
||||
"""
|
||||
Fetch the AssistantInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssistantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AssistantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssistantInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssistantInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
log_queries: Union[bool, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
callback_events: Union[str, object] = values.unset,
|
||||
fallback_actions: Union[object, object] = values.unset,
|
||||
initiation_actions: Union[object, object] = values.unset,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Update the AssistantInstance
|
||||
|
||||
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param callback_url: A user-provided URL to send event callbacks to.
|
||||
:param callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
|
||||
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
|
||||
:param style_sheet: The JSON object that holds the style sheet for the assistant
|
||||
|
||||
:returns: The updated AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"FallbackActions": serialize.object(fallback_actions),
|
||||
"InitiationActions": serialize.object(initiation_actions),
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
log_queries: Union[bool, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
callback_events: Union[str, object] = values.unset,
|
||||
fallback_actions: Union[object, object] = values.unset,
|
||||
initiation_actions: Union[object, object] = values.unset,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantInstance
|
||||
|
||||
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param callback_url: A user-provided URL to send event callbacks to.
|
||||
:param callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
|
||||
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
|
||||
:param style_sheet: The JSON object that holds the style sheet for the assistant
|
||||
|
||||
:returns: The updated AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"FallbackActions": serialize.object(fallback_actions),
|
||||
"InitiationActions": serialize.object(initiation_actions),
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def assistant_fallback_actions(self) -> AssistantFallbackActionsList:
|
||||
"""
|
||||
Access the assistant_fallback_actions
|
||||
"""
|
||||
if self._assistant_fallback_actions is None:
|
||||
self._assistant_fallback_actions = AssistantFallbackActionsList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._assistant_fallback_actions
|
||||
|
||||
@property
|
||||
def assistant_initiation_actions(self) -> AssistantInitiationActionsList:
|
||||
"""
|
||||
Access the assistant_initiation_actions
|
||||
"""
|
||||
if self._assistant_initiation_actions is None:
|
||||
self._assistant_initiation_actions = AssistantInitiationActionsList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._assistant_initiation_actions
|
||||
|
||||
@property
|
||||
def dialogues(self) -> DialogueList:
|
||||
"""
|
||||
Access the dialogues
|
||||
"""
|
||||
if self._dialogues is None:
|
||||
self._dialogues = DialogueList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._dialogues
|
||||
|
||||
@property
|
||||
def field_types(self) -> FieldTypeList:
|
||||
"""
|
||||
Access the field_types
|
||||
"""
|
||||
if self._field_types is None:
|
||||
self._field_types = FieldTypeList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._field_types
|
||||
|
||||
@property
|
||||
def model_builds(self) -> ModelBuildList:
|
||||
"""
|
||||
Access the model_builds
|
||||
"""
|
||||
if self._model_builds is None:
|
||||
self._model_builds = ModelBuildList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._model_builds
|
||||
|
||||
@property
|
||||
def queries(self) -> QueryList:
|
||||
"""
|
||||
Access the queries
|
||||
"""
|
||||
if self._queries is None:
|
||||
self._queries = QueryList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._queries
|
||||
|
||||
@property
|
||||
def style_sheet(self) -> StyleSheetList:
|
||||
"""
|
||||
Access the style_sheet
|
||||
"""
|
||||
if self._style_sheet is None:
|
||||
self._style_sheet = StyleSheetList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._style_sheet
|
||||
|
||||
@property
|
||||
def tasks(self) -> TaskList:
|
||||
"""
|
||||
Access the tasks
|
||||
"""
|
||||
if self._tasks is None:
|
||||
self._tasks = TaskList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._tasks
|
||||
|
||||
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 "<Twilio.Preview.Understand.AssistantContext {}>".format(context)
|
||||
|
||||
|
||||
class AssistantPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> AssistantInstance:
|
||||
"""
|
||||
Build an instance of AssistantInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return AssistantInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.AssistantPage>"
|
||||
|
||||
|
||||
class AssistantList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the AssistantList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Assistants"
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
log_queries: Union[bool, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
callback_events: Union[str, object] = values.unset,
|
||||
fallback_actions: Union[object, object] = values.unset,
|
||||
initiation_actions: Union[object, object] = values.unset,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Create the AssistantInstance
|
||||
|
||||
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param callback_url: A user-provided URL to send event callbacks to.
|
||||
:param callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
|
||||
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
|
||||
:param style_sheet: The JSON object that holds the style sheet for the assistant
|
||||
|
||||
:returns: The created AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"FallbackActions": serialize.object(fallback_actions),
|
||||
"InitiationActions": serialize.object(initiation_actions),
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
log_queries: Union[bool, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
callback_url: Union[str, object] = values.unset,
|
||||
callback_events: Union[str, object] = values.unset,
|
||||
fallback_actions: Union[object, object] = values.unset,
|
||||
initiation_actions: Union[object, object] = values.unset,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Asynchronously create the AssistantInstance
|
||||
|
||||
:param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long.
|
||||
:param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param callback_url: A user-provided URL to send event callbacks to.
|
||||
:param callback_events: Space-separated list of callback events that will trigger callbacks.
|
||||
:param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task.
|
||||
:param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.
|
||||
:param style_sheet: The JSON object that holds the style sheet for the assistant
|
||||
|
||||
:returns: The created AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"FallbackActions": serialize.object(fallback_actions),
|
||||
"InitiationActions": serialize.object(initiation_actions),
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[AssistantInstance]:
|
||||
"""
|
||||
Streams AssistantInstance 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[AssistantInstance]:
|
||||
"""
|
||||
Asynchronously streams AssistantInstance 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 list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[AssistantInstance]:
|
||||
"""
|
||||
Lists AssistantInstance 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[AssistantInstance]:
|
||||
"""
|
||||
Asynchronously lists AssistantInstance 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 page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> AssistantPage:
|
||||
"""
|
||||
Retrieve a single page of AssistantInstance 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 AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return AssistantPage(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,
|
||||
) -> AssistantPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of AssistantInstance 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 AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return AssistantPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> AssistantPage:
|
||||
"""
|
||||
Retrieve a specific page of AssistantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssistantInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return AssistantPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> AssistantPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of AssistantInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of AssistantInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return AssistantPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> AssistantContext:
|
||||
"""
|
||||
Constructs a AssistantContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return AssistantContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> AssistantContext:
|
||||
"""
|
||||
Constructs a AssistantContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return AssistantContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.AssistantList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+279
@@ -0,0 +1,279 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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, Union
|
||||
from twilio.base import serialize, values
|
||||
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
|
||||
|
||||
|
||||
class AssistantFallbackActionsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid:
|
||||
:ivar assistant_sid:
|
||||
:ivar url:
|
||||
:ivar data:
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._context: Optional[AssistantFallbackActionsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AssistantFallbackActionsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AssistantFallbackActionsContext for this AssistantFallbackActionsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AssistantFallbackActionsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "AssistantFallbackActionsInstance":
|
||||
"""
|
||||
Fetch the AssistantFallbackActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantFallbackActionsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AssistantFallbackActionsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssistantFallbackActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantFallbackActionsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, fallback_actions: Union[object, object] = values.unset
|
||||
) -> "AssistantFallbackActionsInstance":
|
||||
"""
|
||||
Update the AssistantFallbackActionsInstance
|
||||
|
||||
:param fallback_actions:
|
||||
|
||||
:returns: The updated AssistantFallbackActionsInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
fallback_actions=fallback_actions,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, fallback_actions: Union[object, object] = values.unset
|
||||
) -> "AssistantFallbackActionsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantFallbackActionsInstance
|
||||
|
||||
:param fallback_actions:
|
||||
|
||||
:returns: The updated AssistantFallbackActionsInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
fallback_actions=fallback_actions,
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.AssistantFallbackActionsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AssistantFallbackActionsContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the AssistantFallbackActionsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/FallbackActions".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> AssistantFallbackActionsInstance:
|
||||
"""
|
||||
Fetch the AssistantFallbackActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantFallbackActionsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssistantFallbackActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AssistantFallbackActionsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssistantFallbackActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantFallbackActionsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssistantFallbackActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, fallback_actions: Union[object, object] = values.unset
|
||||
) -> AssistantFallbackActionsInstance:
|
||||
"""
|
||||
Update the AssistantFallbackActionsInstance
|
||||
|
||||
:param fallback_actions:
|
||||
|
||||
:returns: The updated AssistantFallbackActionsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FallbackActions": serialize.object(fallback_actions),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantFallbackActionsInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, fallback_actions: Union[object, object] = values.unset
|
||||
) -> AssistantFallbackActionsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantFallbackActionsInstance
|
||||
|
||||
:param fallback_actions:
|
||||
|
||||
:returns: The updated AssistantFallbackActionsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FallbackActions": serialize.object(fallback_actions),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantFallbackActionsInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.AssistantFallbackActionsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class AssistantFallbackActionsList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the AssistantFallbackActionsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
|
||||
def get(self) -> AssistantFallbackActionsContext:
|
||||
"""
|
||||
Constructs a AssistantFallbackActionsContext
|
||||
|
||||
"""
|
||||
return AssistantFallbackActionsContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> AssistantFallbackActionsContext:
|
||||
"""
|
||||
Constructs a AssistantFallbackActionsContext
|
||||
|
||||
"""
|
||||
return AssistantFallbackActionsContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.AssistantFallbackActionsList>"
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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, Union
|
||||
from twilio.base import serialize, values
|
||||
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
|
||||
|
||||
|
||||
class AssistantInitiationActionsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid:
|
||||
:ivar assistant_sid:
|
||||
:ivar url:
|
||||
:ivar data:
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._context: Optional[AssistantInitiationActionsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AssistantInitiationActionsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AssistantInitiationActionsContext for this AssistantInitiationActionsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AssistantInitiationActionsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "AssistantInitiationActionsInstance":
|
||||
"""
|
||||
Fetch the AssistantInitiationActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInitiationActionsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AssistantInitiationActionsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssistantInitiationActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInitiationActionsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, initiation_actions: Union[object, object] = values.unset
|
||||
) -> "AssistantInitiationActionsInstance":
|
||||
"""
|
||||
Update the AssistantInitiationActionsInstance
|
||||
|
||||
:param initiation_actions:
|
||||
|
||||
:returns: The updated AssistantInitiationActionsInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
initiation_actions=initiation_actions,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, initiation_actions: Union[object, object] = values.unset
|
||||
) -> "AssistantInitiationActionsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantInitiationActionsInstance
|
||||
|
||||
:param initiation_actions:
|
||||
|
||||
:returns: The updated AssistantInitiationActionsInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
initiation_actions=initiation_actions,
|
||||
)
|
||||
|
||||
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 (
|
||||
"<Twilio.Preview.Understand.AssistantInitiationActionsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class AssistantInitiationActionsContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the AssistantInitiationActionsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/InitiationActions".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> AssistantInitiationActionsInstance:
|
||||
"""
|
||||
Fetch the AssistantInitiationActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInitiationActionsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssistantInitiationActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AssistantInitiationActionsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AssistantInitiationActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched AssistantInitiationActionsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AssistantInitiationActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, initiation_actions: Union[object, object] = values.unset
|
||||
) -> AssistantInitiationActionsInstance:
|
||||
"""
|
||||
Update the AssistantInitiationActionsInstance
|
||||
|
||||
:param initiation_actions:
|
||||
|
||||
:returns: The updated AssistantInitiationActionsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"InitiationActions": serialize.object(initiation_actions),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInitiationActionsInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, initiation_actions: Union[object, object] = values.unset
|
||||
) -> AssistantInitiationActionsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantInitiationActionsInstance
|
||||
|
||||
:param initiation_actions:
|
||||
|
||||
:returns: The updated AssistantInitiationActionsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"InitiationActions": serialize.object(initiation_actions),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInitiationActionsInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
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 (
|
||||
"<Twilio.Preview.Understand.AssistantInitiationActionsContext {}>".format(
|
||||
context
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class AssistantInitiationActionsList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the AssistantInitiationActionsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
|
||||
def get(self) -> AssistantInitiationActionsContext:
|
||||
"""
|
||||
Constructs a AssistantInitiationActionsContext
|
||||
|
||||
"""
|
||||
return AssistantInitiationActionsContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> AssistantInitiationActionsContext:
|
||||
"""
|
||||
Constructs a AssistantInitiationActionsContext
|
||||
|
||||
"""
|
||||
return AssistantInitiationActionsContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.AssistantInitiationActionsList>"
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class DialogueInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Field.
|
||||
:ivar assistant_sid: The unique ID of the parent Assistant.
|
||||
:ivar sid: The unique ID of the Dialogue
|
||||
:ivar data: The dialogue memory object as json
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[DialogueContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "DialogueContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: DialogueContext for this DialogueInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = DialogueContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "DialogueInstance":
|
||||
"""
|
||||
Fetch the DialogueInstance
|
||||
|
||||
|
||||
:returns: The fetched DialogueInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "DialogueInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DialogueInstance
|
||||
|
||||
|
||||
:returns: The fetched DialogueInstance
|
||||
"""
|
||||
return await self._proxy.fetch_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 "<Twilio.Preview.Understand.DialogueInstance {}>".format(context)
|
||||
|
||||
|
||||
class DialogueContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the DialogueContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
:param sid:
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Dialogues/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> DialogueInstance:
|
||||
"""
|
||||
Fetch the DialogueInstance
|
||||
|
||||
|
||||
:returns: The fetched DialogueInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DialogueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> DialogueInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DialogueInstance
|
||||
|
||||
|
||||
:returns: The fetched DialogueInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DialogueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.DialogueContext {}>".format(context)
|
||||
|
||||
|
||||
class DialogueList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the DialogueList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
|
||||
def get(self, sid: str) -> DialogueContext:
|
||||
"""
|
||||
Constructs a DialogueContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return DialogueContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> DialogueContext:
|
||||
"""
|
||||
Constructs a DialogueContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return DialogueContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.DialogueList>"
|
||||
+654
@@ -0,0 +1,654 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.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
|
||||
from twilio.rest.preview.understand.assistant.field_type.field_value import (
|
||||
FieldValueList,
|
||||
)
|
||||
|
||||
|
||||
class FieldTypeInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Field Type.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:ivar links:
|
||||
:ivar assistant_sid: The unique ID of the Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[FieldTypeContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FieldTypeContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FieldTypeContext for this FieldTypeInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FieldTypeContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "FieldTypeInstance":
|
||||
"""
|
||||
Fetch the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldTypeInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FieldTypeInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldTypeInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
) -> "FieldTypeInstance":
|
||||
"""
|
||||
Update the FieldTypeInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
|
||||
:returns: The updated FieldTypeInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
unique_name=unique_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
) -> "FieldTypeInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the FieldTypeInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
|
||||
:returns: The updated FieldTypeInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
unique_name=unique_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def field_values(self) -> FieldValueList:
|
||||
"""
|
||||
Access the field_values
|
||||
"""
|
||||
return self._proxy.field_values
|
||||
|
||||
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 "<Twilio.Preview.Understand.FieldTypeInstance {}>".format(context)
|
||||
|
||||
|
||||
class FieldTypeContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the FieldTypeContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
:param sid:
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/FieldTypes/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._field_values: Optional[FieldValueList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> FieldTypeInstance:
|
||||
"""
|
||||
Fetch the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldTypeInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FieldTypeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FieldTypeInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FieldTypeInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldTypeInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FieldTypeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
) -> FieldTypeInstance:
|
||||
"""
|
||||
Update the FieldTypeInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
|
||||
:returns: The updated FieldTypeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldTypeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
) -> FieldTypeInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the FieldTypeInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
|
||||
:returns: The updated FieldTypeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldTypeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def field_values(self) -> FieldValueList:
|
||||
"""
|
||||
Access the field_values
|
||||
"""
|
||||
if self._field_values is None:
|
||||
self._field_values = FieldValueList(
|
||||
self._version,
|
||||
self._solution["assistant_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._field_values
|
||||
|
||||
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 "<Twilio.Preview.Understand.FieldTypeContext {}>".format(context)
|
||||
|
||||
|
||||
class FieldTypePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> FieldTypeInstance:
|
||||
"""
|
||||
Build an instance of FieldTypeInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return FieldTypeInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.FieldTypePage>"
|
||||
|
||||
|
||||
class FieldTypeList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the FieldTypeList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/FieldTypes".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, unique_name: str, friendly_name: Union[str, object] = values.unset
|
||||
) -> FieldTypeInstance:
|
||||
"""
|
||||
Create the FieldTypeInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
|
||||
:returns: The created FieldTypeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldTypeInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, unique_name: str, friendly_name: Union[str, object] = values.unset
|
||||
) -> FieldTypeInstance:
|
||||
"""
|
||||
Asynchronously create the FieldTypeInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
|
||||
:returns: The created FieldTypeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldTypeInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[FieldTypeInstance]:
|
||||
"""
|
||||
Streams FieldTypeInstance 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[FieldTypeInstance]:
|
||||
"""
|
||||
Asynchronously streams FieldTypeInstance 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 list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[FieldTypeInstance]:
|
||||
"""
|
||||
Lists FieldTypeInstance 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[FieldTypeInstance]:
|
||||
"""
|
||||
Asynchronously lists FieldTypeInstance 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 page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> FieldTypePage:
|
||||
"""
|
||||
Retrieve a single page of FieldTypeInstance 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 FieldTypeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return FieldTypePage(self._version, response, self._solution)
|
||||
|
||||
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,
|
||||
) -> FieldTypePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of FieldTypeInstance 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 FieldTypeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return FieldTypePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> FieldTypePage:
|
||||
"""
|
||||
Retrieve a specific page of FieldTypeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FieldTypeInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return FieldTypePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> FieldTypePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of FieldTypeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FieldTypeInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return FieldTypePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> FieldTypeContext:
|
||||
"""
|
||||
Constructs a FieldTypeContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return FieldTypeContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FieldTypeContext:
|
||||
"""
|
||||
Constructs a FieldTypeContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return FieldTypeContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.FieldTypeList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+577
@@ -0,0 +1,577 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.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 FieldValueInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Field Value.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar field_type_sid: The unique ID of the Field Type associated with this Field Value.
|
||||
:ivar language: An ISO language-country string of the value.
|
||||
:ivar assistant_sid: The unique ID of the Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar value: The Field Value itself.
|
||||
:ivar url:
|
||||
:ivar synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
field_type_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.field_type_sid: Optional[str] = payload.get("field_type_sid")
|
||||
self.language: Optional[str] = payload.get("language")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.value: Optional[str] = payload.get("value")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.synonym_of: Optional[str] = payload.get("synonym_of")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"field_type_sid": field_type_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[FieldValueContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FieldValueContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FieldValueContext for this FieldValueInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FieldValueContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FieldValueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FieldValueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "FieldValueInstance":
|
||||
"""
|
||||
Fetch the FieldValueInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldValueInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FieldValueInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FieldValueInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldValueInstance
|
||||
"""
|
||||
return await self._proxy.fetch_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 "<Twilio.Preview.Understand.FieldValueInstance {}>".format(context)
|
||||
|
||||
|
||||
class FieldValueContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, assistant_sid: str, field_type_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the FieldValueContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
:param field_type_sid:
|
||||
:param sid:
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"field_type_sid": field_type_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FieldValueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FieldValueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> FieldValueInstance:
|
||||
"""
|
||||
Fetch the FieldValueInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldValueInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FieldValueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FieldValueInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FieldValueInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldValueInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FieldValueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.FieldValueContext {}>".format(context)
|
||||
|
||||
|
||||
class FieldValuePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> FieldValueInstance:
|
||||
"""
|
||||
Build an instance of FieldValueInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return FieldValueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.FieldValuePage>"
|
||||
|
||||
|
||||
class FieldValueList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str, field_type_sid: str):
|
||||
"""
|
||||
Initialize the FieldValueList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
:param field_type_sid:
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"field_type_sid": field_type_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self, language: str, value: str, synonym_of: Union[str, object] = values.unset
|
||||
) -> FieldValueInstance:
|
||||
"""
|
||||
Create the FieldValueInstance
|
||||
|
||||
:param language: An ISO language-country string of the value.
|
||||
:param value: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym.
|
||||
|
||||
:returns: The created FieldValueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"Value": value,
|
||||
"SynonymOf": synonym_of,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldValueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, language: str, value: str, synonym_of: Union[str, object] = values.unset
|
||||
) -> FieldValueInstance:
|
||||
"""
|
||||
Asynchronously create the FieldValueInstance
|
||||
|
||||
:param language: An ISO language-country string of the value.
|
||||
:param value: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym.
|
||||
|
||||
:returns: The created FieldValueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"Value": value,
|
||||
"SynonymOf": synonym_of,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldValueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[FieldValueInstance]:
|
||||
"""
|
||||
Streams FieldValueInstance 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 language: An ISO language-country string of the value. For example: *en-US*
|
||||
: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(language=language, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[FieldValueInstance]:
|
||||
"""
|
||||
Asynchronously streams FieldValueInstance 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 language: An ISO language-country string of the value. For example: *en-US*
|
||||
: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(language=language, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[FieldValueInstance]:
|
||||
"""
|
||||
Lists FieldValueInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str language: An ISO language-country string of the value. For example: *en-US*
|
||||
: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(
|
||||
language=language,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[FieldValueInstance]:
|
||||
"""
|
||||
Asynchronously lists FieldValueInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str language: An ISO language-country string of the value. For example: *en-US*
|
||||
: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(
|
||||
language=language,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> FieldValuePage:
|
||||
"""
|
||||
Retrieve a single page of FieldValueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: An ISO language-country string of the value. For example: *en-US*
|
||||
: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 FieldValueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return FieldValuePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> FieldValuePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of FieldValueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: An ISO language-country string of the value. For example: *en-US*
|
||||
: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 FieldValueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return FieldValuePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> FieldValuePage:
|
||||
"""
|
||||
Retrieve a specific page of FieldValueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FieldValueInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return FieldValuePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> FieldValuePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of FieldValueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FieldValueInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return FieldValuePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> FieldValueContext:
|
||||
"""
|
||||
Constructs a FieldValueContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return FieldValueContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FieldValueContext:
|
||||
"""
|
||||
Constructs a FieldValueContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return FieldValueContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
field_type_sid=self._solution["field_type_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.FieldValueList>"
|
||||
+627
@@ -0,0 +1,627 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.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 ModelBuildInstance(InstanceResource):
|
||||
class Status(object):
|
||||
ENQUEUED = "enqueued"
|
||||
BUILDING = "building"
|
||||
COMPLETED = "completed"
|
||||
FAILED = "failed"
|
||||
CANCELED = "canceled"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Model Build.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar assistant_sid: The unique ID of the parent Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar status:
|
||||
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:ivar url:
|
||||
:ivar build_duration: The time in seconds it took to build the model.
|
||||
:ivar error_code:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.status: Optional["ModelBuildInstance.Status"] = payload.get("status")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.build_duration: Optional[int] = deserialize.integer(
|
||||
payload.get("build_duration")
|
||||
)
|
||||
self.error_code: Optional[int] = deserialize.integer(payload.get("error_code"))
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ModelBuildContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ModelBuildContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ModelBuildContext for this ModelBuildInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ModelBuildContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ModelBuildInstance":
|
||||
"""
|
||||
Fetch the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: The fetched ModelBuildInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ModelBuildInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: The fetched ModelBuildInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, unique_name: Union[str, object] = values.unset
|
||||
) -> "ModelBuildInstance":
|
||||
"""
|
||||
Update the ModelBuildInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
|
||||
|
||||
:returns: The updated ModelBuildInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
unique_name=unique_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, unique_name: Union[str, object] = values.unset
|
||||
) -> "ModelBuildInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ModelBuildInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
|
||||
|
||||
:returns: The updated ModelBuildInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
unique_name=unique_name,
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.ModelBuildInstance {}>".format(context)
|
||||
|
||||
|
||||
class ModelBuildContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ModelBuildContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
:param sid:
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/ModelBuilds/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ModelBuildInstance:
|
||||
"""
|
||||
Fetch the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: The fetched ModelBuildInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ModelBuildInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ModelBuildInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ModelBuildInstance
|
||||
|
||||
|
||||
:returns: The fetched ModelBuildInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ModelBuildInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, unique_name: Union[str, object] = values.unset
|
||||
) -> ModelBuildInstance:
|
||||
"""
|
||||
Update the ModelBuildInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
|
||||
|
||||
:returns: The updated ModelBuildInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ModelBuildInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, unique_name: Union[str, object] = values.unset
|
||||
) -> ModelBuildInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ModelBuildInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
|
||||
|
||||
:returns: The updated ModelBuildInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ModelBuildInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.ModelBuildContext {}>".format(context)
|
||||
|
||||
|
||||
class ModelBuildPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ModelBuildInstance:
|
||||
"""
|
||||
Build an instance of ModelBuildInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ModelBuildInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.ModelBuildPage>"
|
||||
|
||||
|
||||
class ModelBuildList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the ModelBuildList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid:
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/ModelBuilds".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
) -> ModelBuildInstance:
|
||||
"""
|
||||
Create the ModelBuildInstance
|
||||
|
||||
:param status_callback:
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
|
||||
|
||||
:returns: The created ModelBuildInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StatusCallback": status_callback,
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ModelBuildInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
status_callback: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
) -> ModelBuildInstance:
|
||||
"""
|
||||
Asynchronously create the ModelBuildInstance
|
||||
|
||||
:param status_callback:
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1
|
||||
|
||||
:returns: The created ModelBuildInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StatusCallback": status_callback,
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ModelBuildInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ModelBuildInstance]:
|
||||
"""
|
||||
Streams ModelBuildInstance 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[ModelBuildInstance]:
|
||||
"""
|
||||
Asynchronously streams ModelBuildInstance 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 list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ModelBuildInstance]:
|
||||
"""
|
||||
Lists ModelBuildInstance 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[ModelBuildInstance]:
|
||||
"""
|
||||
Asynchronously lists ModelBuildInstance 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 page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ModelBuildPage:
|
||||
"""
|
||||
Retrieve a single page of ModelBuildInstance 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 ModelBuildInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ModelBuildPage(self._version, response, self._solution)
|
||||
|
||||
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,
|
||||
) -> ModelBuildPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ModelBuildInstance 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 ModelBuildInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ModelBuildPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ModelBuildPage:
|
||||
"""
|
||||
Retrieve a specific page of ModelBuildInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ModelBuildInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ModelBuildPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ModelBuildPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ModelBuildInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ModelBuildInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ModelBuildPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ModelBuildContext:
|
||||
"""
|
||||
Constructs a ModelBuildContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return ModelBuildContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ModelBuildContext:
|
||||
"""
|
||||
Constructs a ModelBuildContext
|
||||
|
||||
:param sid:
|
||||
"""
|
||||
return ModelBuildContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.ModelBuildList>"
|
||||
@@ -0,0 +1,715 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.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 QueryInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Query.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar results: The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields.
|
||||
:ivar language: An ISO language-country string of the sample.
|
||||
:ivar model_build_sid: The unique ID of the Model Build queried.
|
||||
:ivar query: The end-user's natural language input.
|
||||
:ivar sample_sid: An optional reference to the Sample created from this query.
|
||||
:ivar assistant_sid: The unique ID of the parent Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
:ivar url:
|
||||
:ivar source_channel: The communication channel where this end-user input came from
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.results: Optional[Dict[str, object]] = payload.get("results")
|
||||
self.language: Optional[str] = payload.get("language")
|
||||
self.model_build_sid: Optional[str] = payload.get("model_build_sid")
|
||||
self.query: Optional[str] = payload.get("query")
|
||||
self.sample_sid: Optional[str] = payload.get("sample_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.status: Optional[str] = payload.get("status")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.source_channel: Optional[str] = payload.get("source_channel")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[QueryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "QueryContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: QueryContext for this QueryInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = QueryContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the QueryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the QueryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "QueryInstance":
|
||||
"""
|
||||
Fetch the QueryInstance
|
||||
|
||||
|
||||
:returns: The fetched QueryInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "QueryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the QueryInstance
|
||||
|
||||
|
||||
:returns: The fetched QueryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
sample_sid: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
) -> "QueryInstance":
|
||||
"""
|
||||
Update the QueryInstance
|
||||
|
||||
:param sample_sid: An optional reference to the Sample created from this query.
|
||||
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
|
||||
:returns: The updated QueryInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
sample_sid=sample_sid,
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
sample_sid: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
) -> "QueryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the QueryInstance
|
||||
|
||||
:param sample_sid: An optional reference to the Sample created from this query.
|
||||
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
|
||||
:returns: The updated QueryInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
sample_sid=sample_sid,
|
||||
status=status,
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.QueryInstance {}>".format(context)
|
||||
|
||||
|
||||
class QueryContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the QueryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the parent Assistant.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Queries/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the QueryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the QueryInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> QueryInstance:
|
||||
"""
|
||||
Fetch the QueryInstance
|
||||
|
||||
|
||||
:returns: The fetched QueryInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return QueryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> QueryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the QueryInstance
|
||||
|
||||
|
||||
:returns: The fetched QueryInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return QueryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
sample_sid: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
) -> QueryInstance:
|
||||
"""
|
||||
Update the QueryInstance
|
||||
|
||||
:param sample_sid: An optional reference to the Sample created from this query.
|
||||
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
|
||||
:returns: The updated QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"SampleSid": sample_sid,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
sample_sid: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
) -> QueryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the QueryInstance
|
||||
|
||||
:param sample_sid: An optional reference to the Sample created from this query.
|
||||
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
|
||||
:returns: The updated QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"SampleSid": sample_sid,
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.QueryContext {}>".format(context)
|
||||
|
||||
|
||||
class QueryPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> QueryInstance:
|
||||
"""
|
||||
Build an instance of QueryInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return QueryInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.QueryPage>"
|
||||
|
||||
|
||||
class QueryList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the QueryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the parent Assistant.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Queries".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
language: str,
|
||||
query: str,
|
||||
tasks: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
field: Union[str, object] = values.unset,
|
||||
) -> QueryInstance:
|
||||
"""
|
||||
Create the QueryInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long.
|
||||
:param tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated *task-unique-name-1*, *task-unique-name-2*
|
||||
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format *task-unique-name-1*:*field-unique-name*
|
||||
|
||||
:returns: The created QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"Query": query,
|
||||
"Tasks": tasks,
|
||||
"ModelBuild": model_build,
|
||||
"Field": field,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueryInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
language: str,
|
||||
query: str,
|
||||
tasks: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
field: Union[str, object] = values.unset,
|
||||
) -> QueryInstance:
|
||||
"""
|
||||
Asynchronously create the QueryInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long.
|
||||
:param tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated *task-unique-name-1*, *task-unique-name-2*
|
||||
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format *task-unique-name-1*:*field-unique-name*
|
||||
|
||||
:returns: The created QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"Query": query,
|
||||
"Tasks": tasks,
|
||||
"ModelBuild": model_build,
|
||||
"Field": field,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return QueryInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[QueryInstance]:
|
||||
"""
|
||||
Streams QueryInstance 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 language: An ISO language-country string of the sample.
|
||||
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
: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(
|
||||
language=language,
|
||||
model_build=model_build,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[QueryInstance]:
|
||||
"""
|
||||
Asynchronously streams QueryInstance 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 language: An ISO language-country string of the sample.
|
||||
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
: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(
|
||||
language=language,
|
||||
model_build=model_build,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[QueryInstance]:
|
||||
"""
|
||||
Lists QueryInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str language: An ISO language-country string of the sample.
|
||||
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
: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(
|
||||
language=language,
|
||||
model_build=model_build,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[QueryInstance]:
|
||||
"""
|
||||
Asynchronously lists QueryInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str language: An ISO language-country string of the sample.
|
||||
:param str model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
: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(
|
||||
language=language,
|
||||
model_build=model_build,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> QueryPage:
|
||||
"""
|
||||
Retrieve a single page of QueryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
: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 QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"ModelBuild": model_build,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return QueryPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
model_build: Union[str, object] = values.unset,
|
||||
status: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> QueryPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of QueryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param model_build: The Model Build Sid or unique name of the Model Build to be queried.
|
||||
:param status: A string that described the query status. The values can be: pending_review, reviewed, discarded
|
||||
: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 QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"ModelBuild": model_build,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return QueryPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> QueryPage:
|
||||
"""
|
||||
Retrieve a specific page of QueryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of QueryInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return QueryPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> QueryPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of QueryInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of QueryInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return QueryPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> QueryContext:
|
||||
"""
|
||||
Constructs a QueryContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return QueryContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> QueryContext:
|
||||
"""
|
||||
Constructs a QueryContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return QueryContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.QueryList>"
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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, Union
|
||||
from twilio.base import serialize, values
|
||||
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
|
||||
|
||||
|
||||
class StyleSheetInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Assistant
|
||||
:ivar assistant_sid: The unique ID of the Assistant
|
||||
:ivar url:
|
||||
:ivar data: The JSON style sheet object
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._context: Optional[StyleSheetContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "StyleSheetContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: StyleSheetContext for this StyleSheetInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = StyleSheetContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "StyleSheetInstance":
|
||||
"""
|
||||
Fetch the StyleSheetInstance
|
||||
|
||||
|
||||
:returns: The fetched StyleSheetInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "StyleSheetInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the StyleSheetInstance
|
||||
|
||||
|
||||
:returns: The fetched StyleSheetInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, style_sheet: Union[object, object] = values.unset
|
||||
) -> "StyleSheetInstance":
|
||||
"""
|
||||
Update the StyleSheetInstance
|
||||
|
||||
:param style_sheet: The JSON Style sheet string
|
||||
|
||||
:returns: The updated StyleSheetInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
style_sheet=style_sheet,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, style_sheet: Union[object, object] = values.unset
|
||||
) -> "StyleSheetInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the StyleSheetInstance
|
||||
|
||||
:param style_sheet: The JSON Style sheet string
|
||||
|
||||
:returns: The updated StyleSheetInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
style_sheet=style_sheet,
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.StyleSheetInstance {}>".format(context)
|
||||
|
||||
|
||||
class StyleSheetContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the StyleSheetContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/StyleSheet".format(**self._solution)
|
||||
|
||||
def fetch(self) -> StyleSheetInstance:
|
||||
"""
|
||||
Fetch the StyleSheetInstance
|
||||
|
||||
|
||||
:returns: The fetched StyleSheetInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return StyleSheetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> StyleSheetInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the StyleSheetInstance
|
||||
|
||||
|
||||
:returns: The fetched StyleSheetInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return StyleSheetInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, style_sheet: Union[object, object] = values.unset
|
||||
) -> StyleSheetInstance:
|
||||
"""
|
||||
Update the StyleSheetInstance
|
||||
|
||||
:param style_sheet: The JSON Style sheet string
|
||||
|
||||
:returns: The updated StyleSheetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return StyleSheetInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, style_sheet: Union[object, object] = values.unset
|
||||
) -> StyleSheetInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the StyleSheetInstance
|
||||
|
||||
:param style_sheet: The JSON Style sheet string
|
||||
|
||||
:returns: The updated StyleSheetInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return StyleSheetInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.StyleSheetContext {}>".format(context)
|
||||
|
||||
|
||||
class StyleSheetList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the StyleSheetList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
|
||||
def get(self) -> StyleSheetContext:
|
||||
"""
|
||||
Constructs a StyleSheetContext
|
||||
|
||||
"""
|
||||
return StyleSheetContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> StyleSheetContext:
|
||||
"""
|
||||
Constructs a StyleSheetContext
|
||||
|
||||
"""
|
||||
return StyleSheetContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.StyleSheetList>"
|
||||
+760
@@ -0,0 +1,760 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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, serialize, values
|
||||
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
|
||||
from twilio.rest.preview.understand.assistant.task.field import FieldList
|
||||
from twilio.rest.preview.understand.assistant.task.sample import SampleList
|
||||
from twilio.rest.preview.understand.assistant.task.task_actions import TaskActionsList
|
||||
from twilio.rest.preview.understand.assistant.task.task_statistics import (
|
||||
TaskStatisticsList,
|
||||
)
|
||||
|
||||
|
||||
class TaskInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Task.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:ivar links:
|
||||
:ivar assistant_sid: The unique ID of the Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:ivar actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.actions_url: Optional[str] = payload.get("actions_url")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[TaskContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskContext for this TaskInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the TaskInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the TaskInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "TaskInstance":
|
||||
"""
|
||||
Fetch the TaskInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "TaskInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
actions: Union[object, object] = values.unset,
|
||||
actions_url: Union[str, object] = values.unset,
|
||||
) -> "TaskInstance":
|
||||
"""
|
||||
Update the TaskInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
|
||||
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
unique_name=unique_name,
|
||||
actions=actions,
|
||||
actions_url=actions_url,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
actions: Union[object, object] = values.unset,
|
||||
actions_url: Union[str, object] = values.unset,
|
||||
) -> "TaskInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
|
||||
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
unique_name=unique_name,
|
||||
actions=actions,
|
||||
actions_url=actions_url,
|
||||
)
|
||||
|
||||
@property
|
||||
def fields(self) -> FieldList:
|
||||
"""
|
||||
Access the fields
|
||||
"""
|
||||
return self._proxy.fields
|
||||
|
||||
@property
|
||||
def samples(self) -> SampleList:
|
||||
"""
|
||||
Access the samples
|
||||
"""
|
||||
return self._proxy.samples
|
||||
|
||||
@property
|
||||
def task_actions(self) -> TaskActionsList:
|
||||
"""
|
||||
Access the task_actions
|
||||
"""
|
||||
return self._proxy.task_actions
|
||||
|
||||
@property
|
||||
def statistics(self) -> TaskStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
return self._proxy.statistics
|
||||
|
||||
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 "<Twilio.Preview.Understand.TaskInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the TaskContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{sid}".format(**self._solution)
|
||||
|
||||
self._fields: Optional[FieldList] = None
|
||||
self._samples: Optional[SampleList] = None
|
||||
self._task_actions: Optional[TaskActionsList] = None
|
||||
self._statistics: Optional[TaskStatisticsList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the TaskInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the TaskInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> TaskInstance:
|
||||
"""
|
||||
Fetch the TaskInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> TaskInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
actions: Union[object, object] = values.unset,
|
||||
actions_url: Union[str, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Update the TaskInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
|
||||
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
"Actions": serialize.object(actions),
|
||||
"ActionsUrl": actions_url,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
actions: Union[object, object] = values.unset,
|
||||
actions_url: Union[str, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskInstance
|
||||
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
|
||||
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
"Actions": serialize.object(actions),
|
||||
"ActionsUrl": actions_url,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def fields(self) -> FieldList:
|
||||
"""
|
||||
Access the fields
|
||||
"""
|
||||
if self._fields is None:
|
||||
self._fields = FieldList(
|
||||
self._version,
|
||||
self._solution["assistant_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._fields
|
||||
|
||||
@property
|
||||
def samples(self) -> SampleList:
|
||||
"""
|
||||
Access the samples
|
||||
"""
|
||||
if self._samples is None:
|
||||
self._samples = SampleList(
|
||||
self._version,
|
||||
self._solution["assistant_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._samples
|
||||
|
||||
@property
|
||||
def task_actions(self) -> TaskActionsList:
|
||||
"""
|
||||
Access the task_actions
|
||||
"""
|
||||
if self._task_actions is None:
|
||||
self._task_actions = TaskActionsList(
|
||||
self._version,
|
||||
self._solution["assistant_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._task_actions
|
||||
|
||||
@property
|
||||
def statistics(self) -> TaskStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = TaskStatisticsList(
|
||||
self._version,
|
||||
self._solution["assistant_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._statistics
|
||||
|
||||
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 "<Twilio.Preview.Understand.TaskContext {}>".format(context)
|
||||
|
||||
|
||||
class TaskPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TaskInstance:
|
||||
"""
|
||||
Build an instance of TaskInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TaskInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.TaskPage>"
|
||||
|
||||
|
||||
class TaskList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the TaskList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
unique_name: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
actions: Union[object, object] = values.unset,
|
||||
actions_url: Union[str, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Create the TaskInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
|
||||
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
|
||||
:returns: The created TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"Actions": serialize.object(actions),
|
||||
"ActionsUrl": actions_url,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
unique_name: str,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
actions: Union[object, object] = values.unset,
|
||||
actions_url: Union[str, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Asynchronously create the TaskInstance
|
||||
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
||||
:param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.
|
||||
:param actions_url: User-provided HTTP endpoint where from the assistant fetches actions
|
||||
|
||||
:returns: The created TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"Actions": serialize.object(actions),
|
||||
"ActionsUrl": actions_url,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TaskInstance]:
|
||||
"""
|
||||
Streams TaskInstance 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[TaskInstance]:
|
||||
"""
|
||||
Asynchronously streams TaskInstance 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 list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TaskInstance]:
|
||||
"""
|
||||
Lists TaskInstance 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[TaskInstance]:
|
||||
"""
|
||||
Asynchronously lists TaskInstance 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 page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TaskPage:
|
||||
"""
|
||||
Retrieve a single page of TaskInstance 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 TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TaskPage(self._version, response, self._solution)
|
||||
|
||||
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,
|
||||
) -> TaskPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TaskInstance 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 TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TaskPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TaskPage:
|
||||
"""
|
||||
Retrieve a specific page of TaskInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TaskPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TaskPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TaskInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TaskPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> TaskContext:
|
||||
"""
|
||||
Constructs a TaskContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return TaskContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> TaskContext:
|
||||
"""
|
||||
Constructs a TaskContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return TaskContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.TaskList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+549
@@ -0,0 +1,549 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.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 FieldInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Field.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar field_type: The Field Type of this field. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or sid of a custom Field Type.
|
||||
:ivar task_sid: The unique ID of the Task associated with this Field.
|
||||
:ivar assistant_sid: The unique ID of the parent Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
task_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.field_type: Optional[str] = payload.get("field_type")
|
||||
self.task_sid: Optional[str] = payload.get("task_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[FieldContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FieldContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FieldContext for this FieldInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FieldContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FieldInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FieldInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "FieldInstance":
|
||||
"""
|
||||
Fetch the FieldInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FieldInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FieldInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldInstance
|
||||
"""
|
||||
return await self._proxy.fetch_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 "<Twilio.Preview.Understand.FieldInstance {}>".format(context)
|
||||
|
||||
|
||||
class FieldContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the FieldContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant.
|
||||
:param task_sid: The unique ID of the Task associated with this Field.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FieldInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FieldInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> FieldInstance:
|
||||
"""
|
||||
Fetch the FieldInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FieldInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FieldInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FieldInstance
|
||||
|
||||
|
||||
:returns: The fetched FieldInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FieldInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.FieldContext {}>".format(context)
|
||||
|
||||
|
||||
class FieldPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> FieldInstance:
|
||||
"""
|
||||
Build an instance of FieldInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return FieldInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.FieldPage>"
|
||||
|
||||
|
||||
class FieldList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
|
||||
"""
|
||||
Initialize the FieldList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant.
|
||||
:param task_sid: The unique ID of the Task associated with this Field.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(self, field_type: str, unique_name: str) -> FieldInstance:
|
||||
"""
|
||||
Create the FieldInstance
|
||||
|
||||
:param field_type: The unique name or sid of the FieldType. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or the Field Type sid of a custom Field Type.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
|
||||
:returns: The created FieldInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FieldType": field_type,
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
async def create_async(self, field_type: str, unique_name: str) -> FieldInstance:
|
||||
"""
|
||||
Asynchronously create the FieldInstance
|
||||
|
||||
:param field_type: The unique name or sid of the FieldType. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or the Field Type sid of a custom Field Type.
|
||||
:param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
||||
|
||||
:returns: The created FieldInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FieldType": field_type,
|
||||
"UniqueName": unique_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FieldInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[FieldInstance]:
|
||||
"""
|
||||
Streams FieldInstance 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[FieldInstance]:
|
||||
"""
|
||||
Asynchronously streams FieldInstance 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 list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[FieldInstance]:
|
||||
"""
|
||||
Lists FieldInstance 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[FieldInstance]:
|
||||
"""
|
||||
Asynchronously lists FieldInstance 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 page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> FieldPage:
|
||||
"""
|
||||
Retrieve a single page of FieldInstance 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 FieldInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return FieldPage(self._version, response, self._solution)
|
||||
|
||||
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,
|
||||
) -> FieldPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of FieldInstance 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 FieldInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return FieldPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> FieldPage:
|
||||
"""
|
||||
Retrieve a specific page of FieldInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FieldInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return FieldPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> FieldPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of FieldInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FieldInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return FieldPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> FieldContext:
|
||||
"""
|
||||
Constructs a FieldContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return FieldContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FieldContext:
|
||||
"""
|
||||
Constructs a FieldContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return FieldContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.FieldList>"
|
||||
+697
@@ -0,0 +1,697 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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.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 SampleInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Sample.
|
||||
:ivar date_created: The date that this resource was created
|
||||
:ivar date_updated: The date that this resource was last updated
|
||||
:ivar task_sid: The unique ID of the Task associated with this Sample.
|
||||
:ivar language: An ISO language-country string of the sample.
|
||||
:ivar assistant_sid: The unique ID of the Assistant.
|
||||
:ivar sid: A 34 character string that uniquely identifies this resource.
|
||||
:ivar tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:ivar url:
|
||||
:ivar source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
task_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.task_sid: Optional[str] = payload.get("task_sid")
|
||||
self.language: Optional[str] = payload.get("language")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.tagged_text: Optional[str] = payload.get("tagged_text")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.source_channel: Optional[str] = payload.get("source_channel")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[SampleContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "SampleContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: SampleContext for this SampleInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = SampleContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SampleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SampleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "SampleInstance":
|
||||
"""
|
||||
Fetch the SampleInstance
|
||||
|
||||
|
||||
:returns: The fetched SampleInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "SampleInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SampleInstance
|
||||
|
||||
|
||||
:returns: The fetched SampleInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
tagged_text: Union[str, object] = values.unset,
|
||||
source_channel: Union[str, object] = values.unset,
|
||||
) -> "SampleInstance":
|
||||
"""
|
||||
Update the SampleInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
|
||||
:returns: The updated SampleInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
language=language,
|
||||
tagged_text=tagged_text,
|
||||
source_channel=source_channel,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
tagged_text: Union[str, object] = values.unset,
|
||||
source_channel: Union[str, object] = values.unset,
|
||||
) -> "SampleInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the SampleInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
|
||||
:returns: The updated SampleInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
language=language,
|
||||
tagged_text=tagged_text,
|
||||
source_channel=source_channel,
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.SampleInstance {}>".format(context)
|
||||
|
||||
|
||||
class SampleContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the SampleContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant.
|
||||
:param task_sid: The unique ID of the Task associated with this Sample.
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SampleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SampleInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> SampleInstance:
|
||||
"""
|
||||
Fetch the SampleInstance
|
||||
|
||||
|
||||
:returns: The fetched SampleInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> SampleInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SampleInstance
|
||||
|
||||
|
||||
:returns: The fetched SampleInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
tagged_text: Union[str, object] = values.unset,
|
||||
source_channel: Union[str, object] = values.unset,
|
||||
) -> SampleInstance:
|
||||
"""
|
||||
Update the SampleInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
|
||||
:returns: The updated SampleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"TaggedText": tagged_text,
|
||||
"SourceChannel": source_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
tagged_text: Union[str, object] = values.unset,
|
||||
source_channel: Union[str, object] = values.unset,
|
||||
) -> SampleInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the SampleInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
|
||||
:returns: The updated SampleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"TaggedText": tagged_text,
|
||||
"SourceChannel": source_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.SampleContext {}>".format(context)
|
||||
|
||||
|
||||
class SamplePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> SampleInstance:
|
||||
"""
|
||||
Build an instance of SampleInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.SamplePage>"
|
||||
|
||||
|
||||
class SampleList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
|
||||
"""
|
||||
Initialize the SampleList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the Assistant.
|
||||
:param task_sid: The unique ID of the Task associated with this Sample.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
language: str,
|
||||
tagged_text: str,
|
||||
source_channel: Union[str, object] = values.unset,
|
||||
) -> SampleInstance:
|
||||
"""
|
||||
Create the SampleInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
|
||||
:returns: The created SampleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"TaggedText": tagged_text,
|
||||
"SourceChannel": source_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
language: str,
|
||||
tagged_text: str,
|
||||
source_channel: Union[str, object] = values.unset,
|
||||
) -> SampleInstance:
|
||||
"""
|
||||
Asynchronously create the SampleInstance
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
:param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks.
|
||||
:param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null
|
||||
|
||||
:returns: The created SampleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"TaggedText": tagged_text,
|
||||
"SourceChannel": source_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SampleInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[SampleInstance]:
|
||||
"""
|
||||
Streams SampleInstance 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 language: An ISO language-country string of the sample.
|
||||
: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(language=language, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[SampleInstance]:
|
||||
"""
|
||||
Asynchronously streams SampleInstance 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 language: An ISO language-country string of the sample.
|
||||
: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(language=language, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[SampleInstance]:
|
||||
"""
|
||||
Lists SampleInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str language: An ISO language-country string of the sample.
|
||||
: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(
|
||||
language=language,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[SampleInstance]:
|
||||
"""
|
||||
Asynchronously lists SampleInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str language: An ISO language-country string of the sample.
|
||||
: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(
|
||||
language=language,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> SamplePage:
|
||||
"""
|
||||
Retrieve a single page of SampleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
: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 SampleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return SamplePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
language: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> SamplePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of SampleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: An ISO language-country string of the sample.
|
||||
: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 SampleInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return SamplePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> SamplePage:
|
||||
"""
|
||||
Retrieve a specific page of SampleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SampleInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return SamplePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> SamplePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of SampleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of SampleInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return SamplePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> SampleContext:
|
||||
"""
|
||||
Constructs a SampleContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return SampleContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> SampleContext:
|
||||
"""
|
||||
Constructs a SampleContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this resource.
|
||||
"""
|
||||
return SampleContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.SampleList>"
|
||||
+301
@@ -0,0 +1,301 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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, Union
|
||||
from twilio.base import serialize, values
|
||||
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
|
||||
|
||||
|
||||
class TaskActionsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Field.
|
||||
:ivar assistant_sid: The unique ID of the parent Assistant.
|
||||
:ivar task_sid: The unique ID of the Task.
|
||||
:ivar url:
|
||||
:ivar data:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
task_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.task_sid: Optional[str] = payload.get("task_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
self._context: Optional[TaskActionsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskActionsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskActionsContext for this TaskActionsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskActionsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "TaskActionsInstance":
|
||||
"""
|
||||
Fetch the TaskActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskActionsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "TaskActionsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskActionsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, actions: Union[object, object] = values.unset
|
||||
) -> "TaskActionsInstance":
|
||||
"""
|
||||
Update the TaskActionsInstance
|
||||
|
||||
:param actions: The JSON actions that instruct the Assistant how to perform this task.
|
||||
|
||||
:returns: The updated TaskActionsInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
actions=actions,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, actions: Union[object, object] = values.unset
|
||||
) -> "TaskActionsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskActionsInstance
|
||||
|
||||
:param actions: The JSON actions that instruct the Assistant how to perform this task.
|
||||
|
||||
:returns: The updated TaskActionsInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
actions=actions,
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.TaskActionsInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskActionsContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
|
||||
"""
|
||||
Initialize the TaskActionsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the parent Assistant.
|
||||
:param task_sid: The unique ID of the Task.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Actions".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> TaskActionsInstance:
|
||||
"""
|
||||
Fetch the TaskActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskActionsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> TaskActionsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskActionsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskActionsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, actions: Union[object, object] = values.unset
|
||||
) -> TaskActionsInstance:
|
||||
"""
|
||||
Update the TaskActionsInstance
|
||||
|
||||
:param actions: The JSON actions that instruct the Assistant how to perform this task.
|
||||
|
||||
:returns: The updated TaskActionsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Actions": serialize.object(actions),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, actions: Union[object, object] = values.unset
|
||||
) -> TaskActionsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskActionsInstance
|
||||
|
||||
:param actions: The JSON actions that instruct the Assistant how to perform this task.
|
||||
|
||||
:returns: The updated TaskActionsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Actions": serialize.object(actions),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskActionsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.TaskActionsContext {}>".format(context)
|
||||
|
||||
|
||||
class TaskActionsList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
|
||||
"""
|
||||
Initialize the TaskActionsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the parent Assistant.
|
||||
:param task_sid: The unique ID of the Task.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
|
||||
def get(self) -> TaskActionsContext:
|
||||
"""
|
||||
Constructs a TaskActionsContext
|
||||
|
||||
"""
|
||||
return TaskActionsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> TaskActionsContext:
|
||||
"""
|
||||
Constructs a TaskActionsContext
|
||||
|
||||
"""
|
||||
return TaskActionsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.TaskActionsList>"
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Preview
|
||||
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 deserialize
|
||||
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
|
||||
|
||||
|
||||
class TaskStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The unique ID of the Account that created this Field.
|
||||
:ivar assistant_sid: The unique ID of the parent Assistant.
|
||||
:ivar task_sid: The unique ID of the Task associated with this Field.
|
||||
:ivar samples_count: The total number of Samples associated with this Task.
|
||||
:ivar fields_count: The total number of Fields associated with this Task.
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
task_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assistant_sid: Optional[str] = payload.get("assistant_sid")
|
||||
self.task_sid: Optional[str] = payload.get("task_sid")
|
||||
self.samples_count: Optional[int] = deserialize.integer(
|
||||
payload.get("samples_count")
|
||||
)
|
||||
self.fields_count: Optional[int] = deserialize.integer(
|
||||
payload.get("fields_count")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
self._context: Optional[TaskStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskStatisticsContext for this TaskStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskStatisticsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "TaskStatisticsInstance":
|
||||
"""
|
||||
Fetch the TaskStatisticsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "TaskStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskStatisticsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_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 "<Twilio.Preview.Understand.TaskStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
|
||||
"""
|
||||
Initialize the TaskStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the parent Assistant.
|
||||
:param task_sid: The unique ID of the Task associated with this Field.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Statistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> TaskStatisticsInstance:
|
||||
"""
|
||||
Fetch the TaskStatisticsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskStatisticsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> TaskStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskStatisticsInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskStatisticsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
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 "<Twilio.Preview.Understand.TaskStatisticsContext {}>".format(context)
|
||||
|
||||
|
||||
class TaskStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str, task_sid: str):
|
||||
"""
|
||||
Initialize the TaskStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The unique ID of the parent Assistant.
|
||||
:param task_sid: The unique ID of the Task associated with this Field.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"task_sid": task_sid,
|
||||
}
|
||||
|
||||
def get(self) -> TaskStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskStatisticsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> TaskStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskStatisticsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
task_sid=self._solution["task_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Preview.Understand.TaskStatisticsList>"
|
||||
Reference in New Issue
Block a user