Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
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.domain import Domain
|
||||
from twilio.rest import Client
|
||||
from twilio.rest.autopilot.v1 import V1
|
||||
|
||||
|
||||
class AutopilotBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Autopilot Domain
|
||||
|
||||
:returns: Domain for Autopilot
|
||||
"""
|
||||
super().__init__(twilio, "https://autopilot.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Autopilot
|
||||
"""
|
||||
if self._v1 is None:
|
||||
self._v1 = V1(self)
|
||||
return self._v1
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot>"
|
||||
@@ -0,0 +1,25 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.autopilot.AutopilotBase import AutopilotBase
|
||||
from twilio.rest.autopilot.v1.assistant import AssistantList
|
||||
from twilio.rest.autopilot.v1.restore_assistant import RestoreAssistantList
|
||||
|
||||
|
||||
class Autopilot(AutopilotBase):
|
||||
@property
|
||||
def assistants(self) -> AssistantList:
|
||||
warn(
|
||||
"assistants is deprecated. Use v1.assistants instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.assistants
|
||||
|
||||
@property
|
||||
def restore_assistant(self) -> RestoreAssistantList:
|
||||
warn(
|
||||
"restore_assistant is deprecated. Use v1.restore_assistant instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.restore_assistant
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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.autopilot.v1.assistant import AssistantList
|
||||
from twilio.rest.autopilot.v1.restore_assistant import RestoreAssistantList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Autopilot
|
||||
|
||||
:param domain: The Twilio.autopilot domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._assistants: Optional[AssistantList] = None
|
||||
self._restore_assistant: Optional[RestoreAssistantList] = None
|
||||
|
||||
@property
|
||||
def assistants(self) -> AssistantList:
|
||||
if self._assistants is None:
|
||||
self._assistants = AssistantList(self)
|
||||
return self._assistants
|
||||
|
||||
@property
|
||||
def restore_assistant(self) -> RestoreAssistantList:
|
||||
if self._restore_assistant is None:
|
||||
self._restore_assistant = RestoreAssistantList(self)
|
||||
return self._restore_assistant
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot.V1>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,879 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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.autopilot.v1.assistant.defaults import DefaultsList
|
||||
from twilio.rest.autopilot.v1.assistant.dialogue import DialogueList
|
||||
from twilio.rest.autopilot.v1.assistant.field_type import FieldTypeList
|
||||
from twilio.rest.autopilot.v1.assistant.model_build import ModelBuildList
|
||||
from twilio.rest.autopilot.v1.assistant.query import QueryList
|
||||
from twilio.rest.autopilot.v1.assistant.style_sheet import StyleSheetList
|
||||
from twilio.rest.autopilot.v1.assistant.task import TaskList
|
||||
from twilio.rest.autopilot.v1.assistant.webhook import WebhookList
|
||||
|
||||
|
||||
class AssistantInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:ivar latest_model_build_sid: Reserved.
|
||||
:ivar links: A list of the URLs of the Assistant's related resources.
|
||||
:ivar log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:ivar development_stage: A string describing the state of the assistant.
|
||||
:ivar needs_model_build: Whether model needs to be rebuilt.
|
||||
:ivar sid: The unique string that we created to identify the Assistant resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. It can be up to 64 characters long.
|
||||
:ivar url: The absolute URL of the Assistant resource.
|
||||
:ivar callback_url: Reserved.
|
||||
:ivar callback_events: Reserved.
|
||||
"""
|
||||
|
||||
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.development_stage: Optional[str] = payload.get("development_stage")
|
||||
self.needs_model_build: Optional[bool] = payload.get("needs_model_build")
|
||||
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,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
defaults: Union[object, object] = values.unset,
|
||||
development_stage: Union[str, object] = values.unset,
|
||||
) -> "AssistantInstance":
|
||||
"""
|
||||
Update the AssistantInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param callback_url: Reserved.
|
||||
:param callback_events: Reserved.
|
||||
:param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet)
|
||||
:param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks.
|
||||
:param development_stage: A string describing the state of 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,
|
||||
style_sheet=style_sheet,
|
||||
defaults=defaults,
|
||||
development_stage=development_stage,
|
||||
)
|
||||
|
||||
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,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
defaults: Union[object, object] = values.unset,
|
||||
development_stage: Union[str, object] = values.unset,
|
||||
) -> "AssistantInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param callback_url: Reserved.
|
||||
:param callback_events: Reserved.
|
||||
:param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet)
|
||||
:param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks.
|
||||
:param development_stage: A string describing the state of 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,
|
||||
style_sheet=style_sheet,
|
||||
defaults=defaults,
|
||||
development_stage=development_stage,
|
||||
)
|
||||
|
||||
@property
|
||||
def defaults(self) -> DefaultsList:
|
||||
"""
|
||||
Access the defaults
|
||||
"""
|
||||
return self._proxy.defaults
|
||||
|
||||
@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
|
||||
|
||||
@property
|
||||
def webhooks(self) -> WebhookList:
|
||||
"""
|
||||
Access the webhooks
|
||||
"""
|
||||
return self._proxy.webhooks
|
||||
|
||||
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.Autopilot.V1.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: The Twilio-provided string that uniquely identifies the Assistant resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{sid}".format(**self._solution)
|
||||
|
||||
self._defaults: Optional[DefaultsList] = 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
|
||||
self._webhooks: Optional[WebhookList] = 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,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
defaults: Union[object, object] = values.unset,
|
||||
development_stage: Union[str, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Update the AssistantInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param callback_url: Reserved.
|
||||
:param callback_events: Reserved.
|
||||
:param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet)
|
||||
:param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks.
|
||||
:param development_stage: A string describing the state of the assistant.
|
||||
|
||||
:returns: The updated AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
"Defaults": serialize.object(defaults),
|
||||
"DevelopmentStage": development_stage,
|
||||
}
|
||||
)
|
||||
|
||||
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,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
defaults: Union[object, object] = values.unset,
|
||||
development_stage: Union[str, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the AssistantInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param callback_url: Reserved.
|
||||
:param callback_events: Reserved.
|
||||
:param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet)
|
||||
:param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks.
|
||||
:param development_stage: A string describing the state of the assistant.
|
||||
|
||||
:returns: The updated AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
"Defaults": serialize.object(defaults),
|
||||
"DevelopmentStage": development_stage,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AssistantInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def defaults(self) -> DefaultsList:
|
||||
"""
|
||||
Access the defaults
|
||||
"""
|
||||
if self._defaults is None:
|
||||
self._defaults = DefaultsList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._defaults
|
||||
|
||||
@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
|
||||
|
||||
@property
|
||||
def webhooks(self) -> WebhookList:
|
||||
"""
|
||||
Access the webhooks
|
||||
"""
|
||||
if self._webhooks is None:
|
||||
self._webhooks = WebhookList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._webhooks
|
||||
|
||||
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.Autopilot.V1.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.Autopilot.V1.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,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
defaults: Union[object, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Create the AssistantInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long.
|
||||
:param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param callback_url: Reserved.
|
||||
:param callback_events: Reserved.
|
||||
:param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet)
|
||||
:param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks.
|
||||
|
||||
:returns: The created AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
"Defaults": serialize.object(defaults),
|
||||
}
|
||||
)
|
||||
|
||||
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,
|
||||
style_sheet: Union[object, object] = values.unset,
|
||||
defaults: Union[object, object] = values.unset,
|
||||
) -> AssistantInstance:
|
||||
"""
|
||||
Asynchronously create the AssistantInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long.
|
||||
:param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param callback_url: Reserved.
|
||||
:param callback_events: Reserved.
|
||||
:param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet)
|
||||
:param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks.
|
||||
|
||||
:returns: The created AssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"LogQueries": log_queries,
|
||||
"UniqueName": unique_name,
|
||||
"CallbackUrl": callback_url,
|
||||
"CallbackEvents": callback_events,
|
||||
"StyleSheet": serialize.object(style_sheet),
|
||||
"Defaults": serialize.object(defaults),
|
||||
}
|
||||
)
|
||||
|
||||
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: The Twilio-provided string that uniquely identifies the Assistant resource to update.
|
||||
"""
|
||||
return AssistantContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> AssistantContext:
|
||||
"""
|
||||
Constructs a AssistantContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Assistant resource to update.
|
||||
"""
|
||||
return AssistantContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot.V1.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.
@@ -0,0 +1,273 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 DefaultsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Defaults resource.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar url: The absolute URL of the Defaults resource.
|
||||
:ivar data: The JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations.
|
||||
"""
|
||||
|
||||
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[DefaultsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "DefaultsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: DefaultsContext for this DefaultsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = DefaultsContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "DefaultsInstance":
|
||||
"""
|
||||
Fetch the DefaultsInstance
|
||||
|
||||
|
||||
:returns: The fetched DefaultsInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "DefaultsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DefaultsInstance
|
||||
|
||||
|
||||
:returns: The fetched DefaultsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, defaults: Union[object, object] = values.unset
|
||||
) -> "DefaultsInstance":
|
||||
"""
|
||||
Update the DefaultsInstance
|
||||
|
||||
:param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations.
|
||||
|
||||
:returns: The updated DefaultsInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
defaults=defaults,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, defaults: Union[object, object] = values.unset
|
||||
) -> "DefaultsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the DefaultsInstance
|
||||
|
||||
:param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations.
|
||||
|
||||
:returns: The updated DefaultsInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
defaults=defaults,
|
||||
)
|
||||
|
||||
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.Autopilot.V1.DefaultsInstance {}>".format(context)
|
||||
|
||||
|
||||
class DefaultsContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the DefaultsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Defaults".format(**self._solution)
|
||||
|
||||
def fetch(self) -> DefaultsInstance:
|
||||
"""
|
||||
Fetch the DefaultsInstance
|
||||
|
||||
|
||||
:returns: The fetched DefaultsInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DefaultsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> DefaultsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the DefaultsInstance
|
||||
|
||||
|
||||
:returns: The fetched DefaultsInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return DefaultsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, defaults: Union[object, object] = values.unset
|
||||
) -> DefaultsInstance:
|
||||
"""
|
||||
Update the DefaultsInstance
|
||||
|
||||
:param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations.
|
||||
|
||||
:returns: The updated DefaultsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Defaults": serialize.object(defaults),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return DefaultsInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, defaults: Union[object, object] = values.unset
|
||||
) -> DefaultsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the DefaultsInstance
|
||||
|
||||
:param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations.
|
||||
|
||||
:returns: The updated DefaultsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Defaults": serialize.object(defaults),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return DefaultsInstance(
|
||||
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.Autopilot.V1.DefaultsContext {}>".format(context)
|
||||
|
||||
|
||||
class DefaultsList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the DefaultsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
|
||||
def get(self) -> DefaultsContext:
|
||||
"""
|
||||
Constructs a DefaultsContext
|
||||
|
||||
"""
|
||||
return DefaultsContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> DefaultsContext:
|
||||
"""
|
||||
Constructs a DefaultsContext
|
||||
|
||||
"""
|
||||
return DefaultsContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot.V1.DefaultsList>"
|
||||
@@ -0,0 +1,210 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Dialogue resource.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar sid: The unique string that we created to identify the Dialogue resource.
|
||||
:ivar data: The JSON string that describes the dialogue session object.
|
||||
:ivar url: The absolute URL of the Dialogue resource.
|
||||
"""
|
||||
|
||||
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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Dialogue resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
|
||||
def get(self, sid: str) -> DialogueContext:
|
||||
"""
|
||||
Constructs a DialogueContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Dialogue resource to fetch.
|
||||
"""
|
||||
return DialogueContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> DialogueContext:
|
||||
"""
|
||||
Constructs a DialogueContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Dialogue resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.DialogueList>"
|
||||
+652
@@ -0,0 +1,652 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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.autopilot.v1.assistant.field_type.field_value import FieldValueList
|
||||
|
||||
|
||||
class FieldTypeInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the FieldType resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:ivar links: A list of the URLs of related resources.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar sid: The unique string that we created to identify the FieldType resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar url: The absolute URL of the FieldType resource.
|
||||
"""
|
||||
|
||||
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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
|
||||
: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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
|
||||
: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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the FieldType resource to update.
|
||||
"""
|
||||
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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
|
||||
: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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
|
||||
: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.Autopilot.V1.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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read.
|
||||
|
||||
"""
|
||||
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: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be 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: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be 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: The Twilio-provided string that uniquely identifies the FieldType resource to update.
|
||||
"""
|
||||
return FieldTypeContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FieldTypeContext:
|
||||
"""
|
||||
Constructs a FieldTypeContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the FieldType resource to update.
|
||||
"""
|
||||
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.Autopilot.V1.FieldTypeList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+577
@@ -0,0 +1,577 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the FieldValue resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar field_type_sid: The SID of the Field Type associated with the Field Value.
|
||||
:ivar language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US`
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resource.
|
||||
:ivar sid: The unique string that we created to identify the FieldValue resource.
|
||||
:ivar value: The Field Value data.
|
||||
:ivar url: The absolute URL of the FieldValue resource.
|
||||
:ivar synonym_of: The word for which the field value is a synonym of.
|
||||
"""
|
||||
|
||||
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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resource to fetch.
|
||||
:param field_type_sid: The SID of the Field Type associated with the Field Value to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the FieldValue resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resources to read.
|
||||
:param field_type_sid: The SID of the Field Type associated with the Field Value to read.
|
||||
|
||||
"""
|
||||
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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US`
|
||||
:param value: The Field Value data.
|
||||
:param synonym_of: The string value that indicates which word the field value is a synonym of.
|
||||
|
||||
: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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US`
|
||||
:param value: The Field Value data.
|
||||
:param synonym_of: The string value that indicates which word the field value is a synonym of.
|
||||
|
||||
: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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `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: The Twilio-provided string that uniquely identifies the FieldValue resource to fetch.
|
||||
"""
|
||||
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: The Twilio-provided string that uniquely identifies the FieldValue resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.FieldValueList>"
|
||||
@@ -0,0 +1,627 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ModelBuild resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar sid: The unique string that we created to identify the ModelBuild resource.
|
||||
:ivar status:
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
:ivar url: The absolute URL of the ModelBuild resource.
|
||||
:ivar build_duration: The time in seconds it took to build the model.
|
||||
:ivar error_code: If the `status` for the model build is `failed`, this value is a code to more information about the failure. This value will be null for all other statuses. See [error code dictionary](https://www.twilio.com/docs/api/errors) for a description of the error.
|
||||
"""
|
||||
|
||||
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: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ModelBuild resource to update.
|
||||
"""
|
||||
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: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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.Autopilot.V1.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.Autopilot.V1.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: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read.
|
||||
|
||||
"""
|
||||
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: The URL we should call using a POST method to send status information to your application.
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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: The URL we should call using a POST method to send status information to your application.
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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: The Twilio-provided string that uniquely identifies the ModelBuild resource to update.
|
||||
"""
|
||||
return ModelBuildContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ModelBuildContext:
|
||||
"""
|
||||
Constructs a ModelBuildContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the ModelBuild resource to update.
|
||||
"""
|
||||
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.Autopilot.V1.ModelBuildList>"
|
||||
@@ -0,0 +1,729 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Query resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar results: The natural language analysis results that include the [Task](https://www.twilio.com/docs/autopilot/api/task) recognized and a list of identified [Fields](https://www.twilio.com/docs/autopilot/api/task-field).
|
||||
:ivar language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query. For example: `en-US`.
|
||||
:ivar model_build_sid: The SID of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) queried.
|
||||
:ivar query: The end-user's natural language input.
|
||||
:ivar sample_sid: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar sid: The unique string that we created to identify the Query resource.
|
||||
:ivar status: The status of the Query. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:ivar url: The absolute URL of the Query resource.
|
||||
:ivar source_channel: The communication channel from where the end-user input came.
|
||||
:ivar dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
"""
|
||||
|
||||
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.dialogue_sid: Optional[str] = payload.get("dialogue_sid")
|
||||
|
||||
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: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query.
|
||||
:param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `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: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query.
|
||||
:param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Query resource to update.
|
||||
"""
|
||||
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: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query.
|
||||
:param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `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: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query.
|
||||
:param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `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.Autopilot.V1.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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read.
|
||||
|
||||
"""
|
||||
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,
|
||||
) -> QueryInstance:
|
||||
"""
|
||||
Create the QueryInstance
|
||||
|
||||
:param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new query. For example: `en-US`.
|
||||
:param query: The end-user's natural language input. It can be up to 2048 characters long.
|
||||
:param tasks: The list of tasks to limit the new query to. Tasks are expressed as a comma-separated list of task `unique_name` values. For example, `task-unique_name-1, task-unique_name-2`. Listing specific tasks is useful to constrain the paths that a user can take.
|
||||
:param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
|
||||
:returns: The created QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"Query": query,
|
||||
"Tasks": tasks,
|
||||
"ModelBuild": model_build,
|
||||
}
|
||||
)
|
||||
|
||||
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,
|
||||
) -> QueryInstance:
|
||||
"""
|
||||
Asynchronously create the QueryInstance
|
||||
|
||||
:param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new query. For example: `en-US`.
|
||||
:param query: The end-user's natural language input. It can be up to 2048 characters long.
|
||||
:param tasks: The list of tasks to limit the new query to. Tasks are expressed as a comma-separated list of task `unique_name` values. For example, `task-unique_name-1, task-unique_name-2`. Listing specific tasks is useful to constrain the paths that a user can take.
|
||||
:param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
|
||||
:returns: The created QueryInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Language": language,
|
||||
"Query": query,
|
||||
"Tasks": tasks,
|
||||
"ModelBuild": model_build,
|
||||
}
|
||||
)
|
||||
|
||||
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,
|
||||
dialogue_sid: 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`.
|
||||
:param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
:param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
: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,
|
||||
dialogue_sid=dialogue_sid,
|
||||
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,
|
||||
dialogue_sid: 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`.
|
||||
:param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
:param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
: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,
|
||||
dialogue_sid=dialogue_sid,
|
||||
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,
|
||||
dialogue_sid: 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`.
|
||||
:param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
:param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
: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,
|
||||
dialogue_sid=dialogue_sid,
|
||||
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,
|
||||
dialogue_sid: 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`.
|
||||
:param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
:param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
: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,
|
||||
dialogue_sid=dialogue_sid,
|
||||
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,
|
||||
dialogue_sid: 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`.
|
||||
:param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
:param status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:param dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
: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,
|
||||
"DialogueSid": dialogue_sid,
|
||||
"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,
|
||||
dialogue_sid: 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`.
|
||||
:param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried.
|
||||
:param status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded`
|
||||
:param dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue).
|
||||
: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,
|
||||
"DialogueSid": dialogue_sid,
|
||||
"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: The Twilio-provided string that uniquely identifies the Query resource to update.
|
||||
"""
|
||||
return QueryContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> QueryContext:
|
||||
"""
|
||||
Constructs a QueryContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Query resource to update.
|
||||
"""
|
||||
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.Autopilot.V1.QueryList>"
|
||||
@@ -0,0 +1,273 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the StyleSheet resource.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar url: The absolute URL of the StyleSheet resource.
|
||||
:ivar data: The JSON string that describes the 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 string that describes the style sheet object.
|
||||
|
||||
: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 string that describes the style sheet object.
|
||||
|
||||
: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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update.
|
||||
"""
|
||||
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 string that describes the style sheet object.
|
||||
|
||||
: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 string that describes the style sheet object.
|
||||
|
||||
: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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.
|
||||
|
||||
"""
|
||||
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.Autopilot.V1.StyleSheetList>"
|
||||
+758
@@ -0,0 +1,758 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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.autopilot.v1.assistant.task.field import FieldList
|
||||
from twilio.rest.autopilot.v1.assistant.task.sample import SampleList
|
||||
from twilio.rest.autopilot.v1.assistant.task.task_actions import TaskActionsList
|
||||
from twilio.rest.autopilot.v1.assistant.task.task_statistics import TaskStatisticsList
|
||||
|
||||
|
||||
class TaskInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Task resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:ivar links: A list of the URLs of related resources.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar sid: The unique string that we created to identify the Task resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar actions_url: The URL from which the Assistant can fetch actions.
|
||||
:ivar url: The absolute URL of the Task resource.
|
||||
"""
|
||||
|
||||
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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
:param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task.
|
||||
:param actions_url: The URL from which the Assistant can fetch 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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
:param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task.
|
||||
:param actions_url: The URL from which the Assistant can fetch 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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Task resource to update.
|
||||
"""
|
||||
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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
:param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task.
|
||||
:param actions_url: The URL from which the Assistant can fetch 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 descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
:param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task.
|
||||
:param actions_url: The URL from which the Assistant can fetch 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.Autopilot.V1.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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read.
|
||||
|
||||
"""
|
||||
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: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long.
|
||||
:param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. It is optional and not unique.
|
||||
:param actions_url: The URL from which the Assistant can fetch 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: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long.
|
||||
:param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. It is optional and not unique.
|
||||
:param actions_url: The URL from which the Assistant can fetch 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: The Twilio-provided string that uniquely identifies the Task resource to update.
|
||||
"""
|
||||
return TaskContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> TaskContext:
|
||||
"""
|
||||
Constructs a TaskContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Task resource to update.
|
||||
"""
|
||||
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.Autopilot.V1.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.
@@ -0,0 +1,549 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Field resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar field_type: The Field Type of the field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the unique_name, or the SID of a custom Field Type.
|
||||
:ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with this Field.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource.
|
||||
:ivar sid: The unique string that we created to identify the Field resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar url: The absolute URL of the Field resource.
|
||||
"""
|
||||
|
||||
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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource to fetch.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resource to fetch.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Field resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resources to read.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resources to read.
|
||||
|
||||
"""
|
||||
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 Field Type of the new field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the `unique_name`, or the `sid` of a custom Field Type.
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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 Field Type of the new field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the `unique_name`, or the `sid` of a custom Field Type.
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
|
||||
|
||||
: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: The Twilio-provided string that uniquely identifies the Field resource to fetch.
|
||||
"""
|
||||
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: The Twilio-provided string that uniquely identifies the Field resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.FieldList>"
|
||||
@@ -0,0 +1,697 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sample resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the resource.
|
||||
:ivar language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource.
|
||||
:ivar sid: The unique string that we created to identify the Sample resource.
|
||||
:ivar tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:ivar url: The absolute URL of the Sample resource.
|
||||
:ivar source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
"""
|
||||
|
||||
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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`.
|
||||
:param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
|
||||
: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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`.
|
||||
:param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
|
||||
: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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource to update.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the Sample resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Sample resource to update.
|
||||
"""
|
||||
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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`.
|
||||
:param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
|
||||
: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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`.
|
||||
:param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
|
||||
: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.Autopilot.V1.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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resources to read.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the Sample resources to read.
|
||||
|
||||
"""
|
||||
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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new sample. For example: `en-US`.
|
||||
:param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:param source_channel: The communication channel from which the new sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
|
||||
: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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new sample. For example: `en-US`.
|
||||
:param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging).
|
||||
:param source_channel: The communication channel from which the new sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.
|
||||
|
||||
: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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. 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[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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. 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[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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. 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[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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. 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,
|
||||
) -> SamplePage:
|
||||
"""
|
||||
Retrieve a single page of SampleInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. 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 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: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. 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 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: The Twilio-provided string that uniquely identifies the Sample resource to update.
|
||||
"""
|
||||
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: The Twilio-provided string that uniquely identifies the Sample resource to update.
|
||||
"""
|
||||
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.Autopilot.V1.SampleList>"
|
||||
+301
@@ -0,0 +1,301 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskActions resource.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource.
|
||||
:ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the resource.
|
||||
:ivar url: The absolute URL of the TaskActions resource.
|
||||
:ivar data: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task.
|
||||
"""
|
||||
|
||||
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 string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the 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 string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the 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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task for which the task actions to update were defined.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the task actions to update were defined.
|
||||
"""
|
||||
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 string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the 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 string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the 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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task for which the task actions to fetch were defined.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the task actions to fetch were defined.
|
||||
|
||||
"""
|
||||
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.Autopilot.V1.TaskActionsList>"
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskStatistics resource.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource.
|
||||
:ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the statistics were collected.
|
||||
:ivar samples_count: The total number of [Samples](https://www.twilio.com/docs/autopilot/api/task-sample) associated with the Task.
|
||||
:ivar fields_count: The total number of [Fields](https://www.twilio.com/docs/autopilot/api/task-field) associated with the Task.
|
||||
:ivar url: The absolute URL of the TaskStatistics resource.
|
||||
"""
|
||||
|
||||
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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) that is associated with the resource to fetch.
|
||||
"""
|
||||
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.Autopilot.V1.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 SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.
|
||||
:param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) that is associated with the resource to fetch.
|
||||
|
||||
"""
|
||||
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.Autopilot.V1.TaskStatisticsList>"
|
||||
@@ -0,0 +1,671 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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 WebhookInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar url: The absolute URL of the Webhook resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Webhook resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
|
||||
:ivar sid: The unique string that we created to identify the Webhook resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar events: The list of space-separated events that this Webhook is subscribed to.
|
||||
:ivar webhook_url: The URL associated with this Webhook.
|
||||
:ivar webhook_method: The method used when calling the webhook's URL.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
assistant_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.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.events: Optional[str] = payload.get("events")
|
||||
self.webhook_url: Optional[str] = payload.get("webhook_url")
|
||||
self.webhook_method: Optional[str] = payload.get("webhook_method")
|
||||
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WebhookContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WebhookContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WebhookContext for this WebhookInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WebhookContext(
|
||||
self._version,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "WebhookInstance":
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
events: Union[str, object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
webhook_method: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param events: The list of space-separated events that this Webhook will subscribe to.
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param webhook_method: The method to be used when calling the webhook's URL.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
unique_name=unique_name,
|
||||
events=events,
|
||||
webhook_url=webhook_url,
|
||||
webhook_method=webhook_method,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
events: Union[str, object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
webhook_method: Union[str, object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param events: The list of space-separated events that this Webhook will subscribe to.
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param webhook_method: The method to be used when calling the webhook's URL.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
unique_name=unique_name,
|
||||
events=events,
|
||||
webhook_url=webhook_url,
|
||||
webhook_method=webhook_method,
|
||||
)
|
||||
|
||||
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.Autopilot.V1.WebhookInstance {}>".format(context)
|
||||
|
||||
|
||||
class WebhookContext(InstanceContext):
|
||||
def __init__(self, version: Version, assistant_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the WebhookContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Webhooks/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
: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 WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> WebhookInstance:
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
assistant_sid=self._solution["assistant_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
unique_name: Union[str, object] = values.unset,
|
||||
events: Union[str, object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
webhook_method: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param events: The list of space-separated events that this Webhook will subscribe to.
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param webhook_method: The method to be used when calling the webhook's URL.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"Events": events,
|
||||
"WebhookUrl": webhook_url,
|
||||
"WebhookMethod": webhook_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
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,
|
||||
events: Union[str, object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
webhook_method: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param events: The list of space-separated events that this Webhook will subscribe to.
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param webhook_method: The method to be used when calling the webhook's URL.
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"Events": events,
|
||||
"WebhookUrl": webhook_url,
|
||||
"WebhookMethod": webhook_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
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.Autopilot.V1.WebhookContext {}>".format(context)
|
||||
|
||||
|
||||
class WebhookPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance:
|
||||
"""
|
||||
Build an instance of WebhookInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WebhookInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot.V1.WebhookPage>"
|
||||
|
||||
|
||||
class WebhookList(ListResource):
|
||||
def __init__(self, version: Version, assistant_sid: str):
|
||||
"""
|
||||
Initialize the WebhookList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"assistant_sid": assistant_sid,
|
||||
}
|
||||
self._uri = "/Assistants/{assistant_sid}/Webhooks".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
unique_name: str,
|
||||
events: str,
|
||||
webhook_url: str,
|
||||
webhook_method: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Create the WebhookInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param events: The list of space-separated events that this Webhook will subscribe to.
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param webhook_method: The method to be used when calling the webhook's URL.
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"Events": events,
|
||||
"WebhookUrl": webhook_url,
|
||||
"WebhookMethod": webhook_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
unique_name: str,
|
||||
events: str,
|
||||
webhook_url: str,
|
||||
webhook_method: Union[str, object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronously create the WebhookInstance
|
||||
|
||||
:param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.
|
||||
:param events: The list of space-separated events that this Webhook will subscribe to.
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param webhook_method: The method to be used when calling the webhook's URL.
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"Events": events,
|
||||
"WebhookUrl": webhook_url,
|
||||
"WebhookMethod": webhook_method,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, assistant_sid=self._solution["assistant_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WebhookInstance]:
|
||||
"""
|
||||
Streams WebhookInstance 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[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously streams WebhookInstance 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[WebhookInstance]:
|
||||
"""
|
||||
Lists WebhookInstance 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[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously lists WebhookInstance 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,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a single page of WebhookInstance 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 WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WebhookPage(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,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WebhookInstance 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 WebhookInstance
|
||||
"""
|
||||
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 WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, assistant_sid=self._solution["assistant_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot.V1.WebhookList>"
|
||||
@@ -0,0 +1,136 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Autopilot
|
||||
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, Optional
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class RestoreAssistantInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource.
|
||||
:ivar sid: The unique string that we created to identify the Assistant resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long.
|
||||
:ivar needs_model_build: Whether model needs to be rebuilt.
|
||||
:ivar latest_model_build_sid: Reserved.
|
||||
:ivar log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.
|
||||
:ivar development_stage: A string describing the state of the assistant.
|
||||
:ivar callback_url: Reserved.
|
||||
:ivar callback_events: Reserved.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.sid: Optional[str] = payload.get("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.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.needs_model_build: Optional[bool] = payload.get("needs_model_build")
|
||||
self.latest_model_build_sid: Optional[str] = payload.get(
|
||||
"latest_model_build_sid"
|
||||
)
|
||||
self.log_queries: Optional[bool] = payload.get("log_queries")
|
||||
self.development_stage: Optional[str] = payload.get("development_stage")
|
||||
self.callback_url: Optional[str] = payload.get("callback_url")
|
||||
self.callback_events: Optional[str] = payload.get("callback_events")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Autopilot.V1.RestoreAssistantInstance>"
|
||||
|
||||
|
||||
class RestoreAssistantList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the RestoreAssistantList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Assistants/Restore"
|
||||
|
||||
def update(self, assistant: str) -> RestoreAssistantInstance:
|
||||
"""
|
||||
Update the RestoreAssistantInstance
|
||||
|
||||
:param assistant: The Twilio-provided string that uniquely identifies the Assistant resource to restore.
|
||||
|
||||
:returns: The created RestoreAssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Assistant": assistant,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RestoreAssistantInstance(self._version, payload)
|
||||
|
||||
async def update_async(self, assistant: str) -> RestoreAssistantInstance:
|
||||
"""
|
||||
Asynchronously update the RestoreAssistantInstance
|
||||
|
||||
:param assistant: The Twilio-provided string that uniquely identifies the Assistant resource to restore.
|
||||
|
||||
:returns: The created RestoreAssistantInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Assistant": assistant,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RestoreAssistantInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Autopilot.V1.RestoreAssistantList>"
|
||||
Reference in New Issue
Block a user