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.taskrouter.v1 import V1
|
||||
|
||||
|
||||
class TaskrouterBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Taskrouter Domain
|
||||
|
||||
:returns: Domain for Taskrouter
|
||||
"""
|
||||
super().__init__(twilio, "https://taskrouter.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Taskrouter
|
||||
"""
|
||||
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.Taskrouter>"
|
||||
@@ -0,0 +1,15 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.taskrouter.TaskrouterBase import TaskrouterBase
|
||||
from twilio.rest.taskrouter.v1.workspace import WorkspaceList
|
||||
|
||||
|
||||
class Taskrouter(TaskrouterBase):
|
||||
@property
|
||||
def workspaces(self) -> WorkspaceList:
|
||||
warn(
|
||||
"workspaces is deprecated. Use v1.workspaces instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.workspaces
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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.taskrouter.v1.workspace import WorkspaceList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Taskrouter
|
||||
|
||||
:param domain: The Twilio.taskrouter domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._workspaces: Optional[WorkspaceList] = None
|
||||
|
||||
@property
|
||||
def workspaces(self) -> WorkspaceList:
|
||||
if self._workspaces is None:
|
||||
self._workspaces = WorkspaceList(self)
|
||||
return self._workspaces
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1>"
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,944 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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.taskrouter.v1.workspace.activity import ActivityList
|
||||
from twilio.rest.taskrouter.v1.workspace.event import EventList
|
||||
from twilio.rest.taskrouter.v1.workspace.task import TaskList
|
||||
from twilio.rest.taskrouter.v1.workspace.task_channel import TaskChannelList
|
||||
from twilio.rest.taskrouter.v1.workspace.task_queue import TaskQueueList
|
||||
from twilio.rest.taskrouter.v1.workspace.worker import WorkerList
|
||||
from twilio.rest.taskrouter.v1.workspace.workflow import WorkflowList
|
||||
from twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics import (
|
||||
WorkspaceCumulativeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics import (
|
||||
WorkspaceRealTimeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.workspace_statistics import (
|
||||
WorkspaceStatisticsList,
|
||||
)
|
||||
|
||||
|
||||
class WorkspaceInstance(InstanceResource):
|
||||
class QueueOrder(object):
|
||||
FIFO = "FIFO"
|
||||
LIFO = "LIFO"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workspace resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar default_activity_name: The name of the default activity.
|
||||
:ivar default_activity_sid: The SID of the Activity that will be used when new Workers are created in the Workspace.
|
||||
:ivar event_callback_url: The URL we call when an event occurs. If provided, the Workspace will publish events to this URL, for example, to collect data for reporting. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:ivar events_filter: The list of Workspace events for which to call `event_callback_url`. For example, if `EventsFilter=task.created, task.canceled, worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:ivar friendly_name: The string that you assigned to describe the Workspace resource. For example `Customer Support` or `2014 Election Campaign`.
|
||||
:ivar multi_task_enabled: Whether multi-tasking is enabled. The default is `true`, which enables multi-tasking. Multi-tasking allows Workers to handle multiple Tasks simultaneously. When enabled (`true`), each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking each Worker would only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:ivar sid: The unique string that we created to identify the Workspace resource.
|
||||
:ivar timeout_activity_name: The name of the timeout activity.
|
||||
:ivar timeout_activity_sid: The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.
|
||||
:ivar prioritize_queue_order:
|
||||
:ivar url: The absolute URL of the Workspace resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
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.default_activity_name: Optional[str] = payload.get("default_activity_name")
|
||||
self.default_activity_sid: Optional[str] = payload.get("default_activity_sid")
|
||||
self.event_callback_url: Optional[str] = payload.get("event_callback_url")
|
||||
self.events_filter: Optional[str] = payload.get("events_filter")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.multi_task_enabled: Optional[bool] = payload.get("multi_task_enabled")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.timeout_activity_name: Optional[str] = payload.get("timeout_activity_name")
|
||||
self.timeout_activity_sid: Optional[str] = payload.get("timeout_activity_sid")
|
||||
self.prioritize_queue_order: Optional[
|
||||
"WorkspaceInstance.QueueOrder"
|
||||
] = payload.get("prioritize_queue_order")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WorkspaceContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkspaceContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkspaceContext for this WorkspaceInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkspaceContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WorkspaceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WorkspaceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "WorkspaceInstance":
|
||||
"""
|
||||
Fetch the WorkspaceInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkspaceInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WorkspaceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkspaceInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
default_activity_sid: Union[str, object] = values.unset,
|
||||
event_callback_url: Union[str, object] = values.unset,
|
||||
events_filter: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
multi_task_enabled: Union[bool, object] = values.unset,
|
||||
timeout_activity_sid: Union[str, object] = values.unset,
|
||||
prioritize_queue_order: Union[
|
||||
"WorkspaceInstance.QueueOrder", object
|
||||
] = values.unset,
|
||||
) -> "WorkspaceInstance":
|
||||
"""
|
||||
Update the WorkspaceInstance
|
||||
|
||||
:param default_activity_sid: The SID of the Activity that will be used when new Workers are created in the Workspace.
|
||||
:param event_callback_url: The URL we should call when an event occurs. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:param events_filter: The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:param friendly_name: A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`.
|
||||
:param multi_task_enabled: Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can't be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:param timeout_activity_sid: The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.
|
||||
:param prioritize_queue_order:
|
||||
|
||||
:returns: The updated WorkspaceInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
default_activity_sid=default_activity_sid,
|
||||
event_callback_url=event_callback_url,
|
||||
events_filter=events_filter,
|
||||
friendly_name=friendly_name,
|
||||
multi_task_enabled=multi_task_enabled,
|
||||
timeout_activity_sid=timeout_activity_sid,
|
||||
prioritize_queue_order=prioritize_queue_order,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
default_activity_sid: Union[str, object] = values.unset,
|
||||
event_callback_url: Union[str, object] = values.unset,
|
||||
events_filter: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
multi_task_enabled: Union[bool, object] = values.unset,
|
||||
timeout_activity_sid: Union[str, object] = values.unset,
|
||||
prioritize_queue_order: Union[
|
||||
"WorkspaceInstance.QueueOrder", object
|
||||
] = values.unset,
|
||||
) -> "WorkspaceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkspaceInstance
|
||||
|
||||
:param default_activity_sid: The SID of the Activity that will be used when new Workers are created in the Workspace.
|
||||
:param event_callback_url: The URL we should call when an event occurs. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:param events_filter: The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:param friendly_name: A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`.
|
||||
:param multi_task_enabled: Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can't be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:param timeout_activity_sid: The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.
|
||||
:param prioritize_queue_order:
|
||||
|
||||
:returns: The updated WorkspaceInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
default_activity_sid=default_activity_sid,
|
||||
event_callback_url=event_callback_url,
|
||||
events_filter=events_filter,
|
||||
friendly_name=friendly_name,
|
||||
multi_task_enabled=multi_task_enabled,
|
||||
timeout_activity_sid=timeout_activity_sid,
|
||||
prioritize_queue_order=prioritize_queue_order,
|
||||
)
|
||||
|
||||
@property
|
||||
def activities(self) -> ActivityList:
|
||||
"""
|
||||
Access the activities
|
||||
"""
|
||||
return self._proxy.activities
|
||||
|
||||
@property
|
||||
def events(self) -> EventList:
|
||||
"""
|
||||
Access the events
|
||||
"""
|
||||
return self._proxy.events
|
||||
|
||||
@property
|
||||
def tasks(self) -> TaskList:
|
||||
"""
|
||||
Access the tasks
|
||||
"""
|
||||
return self._proxy.tasks
|
||||
|
||||
@property
|
||||
def task_channels(self) -> TaskChannelList:
|
||||
"""
|
||||
Access the task_channels
|
||||
"""
|
||||
return self._proxy.task_channels
|
||||
|
||||
@property
|
||||
def task_queues(self) -> TaskQueueList:
|
||||
"""
|
||||
Access the task_queues
|
||||
"""
|
||||
return self._proxy.task_queues
|
||||
|
||||
@property
|
||||
def workers(self) -> WorkerList:
|
||||
"""
|
||||
Access the workers
|
||||
"""
|
||||
return self._proxy.workers
|
||||
|
||||
@property
|
||||
def workflows(self) -> WorkflowList:
|
||||
"""
|
||||
Access the workflows
|
||||
"""
|
||||
return self._proxy.workflows
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> WorkspaceCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
return self._proxy.cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> WorkspaceRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
return self._proxy.real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkspaceStatisticsList:
|
||||
"""
|
||||
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.Taskrouter.V1.WorkspaceInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkspaceContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The SID of the Workspace resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{sid}".format(**self._solution)
|
||||
|
||||
self._activities: Optional[ActivityList] = None
|
||||
self._events: Optional[EventList] = None
|
||||
self._tasks: Optional[TaskList] = None
|
||||
self._task_channels: Optional[TaskChannelList] = None
|
||||
self._task_queues: Optional[TaskQueueList] = None
|
||||
self._workers: Optional[WorkerList] = None
|
||||
self._workflows: Optional[WorkflowList] = None
|
||||
self._cumulative_statistics: Optional[WorkspaceCumulativeStatisticsList] = None
|
||||
self._real_time_statistics: Optional[WorkspaceRealTimeStatisticsList] = None
|
||||
self._statistics: Optional[WorkspaceStatisticsList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WorkspaceInstance
|
||||
|
||||
|
||||
: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 WorkspaceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> WorkspaceInstance:
|
||||
"""
|
||||
Fetch the WorkspaceInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkspaceInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkspaceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WorkspaceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkspaceInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkspaceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
default_activity_sid: Union[str, object] = values.unset,
|
||||
event_callback_url: Union[str, object] = values.unset,
|
||||
events_filter: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
multi_task_enabled: Union[bool, object] = values.unset,
|
||||
timeout_activity_sid: Union[str, object] = values.unset,
|
||||
prioritize_queue_order: Union[
|
||||
"WorkspaceInstance.QueueOrder", object
|
||||
] = values.unset,
|
||||
) -> WorkspaceInstance:
|
||||
"""
|
||||
Update the WorkspaceInstance
|
||||
|
||||
:param default_activity_sid: The SID of the Activity that will be used when new Workers are created in the Workspace.
|
||||
:param event_callback_url: The URL we should call when an event occurs. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:param events_filter: The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:param friendly_name: A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`.
|
||||
:param multi_task_enabled: Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can't be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:param timeout_activity_sid: The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.
|
||||
:param prioritize_queue_order:
|
||||
|
||||
:returns: The updated WorkspaceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DefaultActivitySid": default_activity_sid,
|
||||
"EventCallbackUrl": event_callback_url,
|
||||
"EventsFilter": events_filter,
|
||||
"FriendlyName": friendly_name,
|
||||
"MultiTaskEnabled": multi_task_enabled,
|
||||
"TimeoutActivitySid": timeout_activity_sid,
|
||||
"PrioritizeQueueOrder": prioritize_queue_order,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkspaceInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
default_activity_sid: Union[str, object] = values.unset,
|
||||
event_callback_url: Union[str, object] = values.unset,
|
||||
events_filter: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
multi_task_enabled: Union[bool, object] = values.unset,
|
||||
timeout_activity_sid: Union[str, object] = values.unset,
|
||||
prioritize_queue_order: Union[
|
||||
"WorkspaceInstance.QueueOrder", object
|
||||
] = values.unset,
|
||||
) -> WorkspaceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkspaceInstance
|
||||
|
||||
:param default_activity_sid: The SID of the Activity that will be used when new Workers are created in the Workspace.
|
||||
:param event_callback_url: The URL we should call when an event occurs. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:param events_filter: The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:param friendly_name: A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`.
|
||||
:param multi_task_enabled: Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can't be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:param timeout_activity_sid: The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.
|
||||
:param prioritize_queue_order:
|
||||
|
||||
:returns: The updated WorkspaceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DefaultActivitySid": default_activity_sid,
|
||||
"EventCallbackUrl": event_callback_url,
|
||||
"EventsFilter": events_filter,
|
||||
"FriendlyName": friendly_name,
|
||||
"MultiTaskEnabled": multi_task_enabled,
|
||||
"TimeoutActivitySid": timeout_activity_sid,
|
||||
"PrioritizeQueueOrder": prioritize_queue_order,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkspaceInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def activities(self) -> ActivityList:
|
||||
"""
|
||||
Access the activities
|
||||
"""
|
||||
if self._activities is None:
|
||||
self._activities = ActivityList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._activities
|
||||
|
||||
@property
|
||||
def events(self) -> EventList:
|
||||
"""
|
||||
Access the events
|
||||
"""
|
||||
if self._events is None:
|
||||
self._events = EventList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._events
|
||||
|
||||
@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 task_channels(self) -> TaskChannelList:
|
||||
"""
|
||||
Access the task_channels
|
||||
"""
|
||||
if self._task_channels is None:
|
||||
self._task_channels = TaskChannelList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._task_channels
|
||||
|
||||
@property
|
||||
def task_queues(self) -> TaskQueueList:
|
||||
"""
|
||||
Access the task_queues
|
||||
"""
|
||||
if self._task_queues is None:
|
||||
self._task_queues = TaskQueueList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._task_queues
|
||||
|
||||
@property
|
||||
def workers(self) -> WorkerList:
|
||||
"""
|
||||
Access the workers
|
||||
"""
|
||||
if self._workers is None:
|
||||
self._workers = WorkerList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._workers
|
||||
|
||||
@property
|
||||
def workflows(self) -> WorkflowList:
|
||||
"""
|
||||
Access the workflows
|
||||
"""
|
||||
if self._workflows is None:
|
||||
self._workflows = WorkflowList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._workflows
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> WorkspaceCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
if self._cumulative_statistics is None:
|
||||
self._cumulative_statistics = WorkspaceCumulativeStatisticsList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> WorkspaceRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
if self._real_time_statistics is None:
|
||||
self._real_time_statistics = WorkspaceRealTimeStatisticsList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkspaceStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = WorkspaceStatisticsList(
|
||||
self._version,
|
||||
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.Taskrouter.V1.WorkspaceContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkspacePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WorkspaceInstance:
|
||||
"""
|
||||
Build an instance of WorkspaceInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WorkspaceInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkspacePage>"
|
||||
|
||||
|
||||
class WorkspaceList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the WorkspaceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Workspaces"
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
event_callback_url: Union[str, object] = values.unset,
|
||||
events_filter: Union[str, object] = values.unset,
|
||||
multi_task_enabled: Union[bool, object] = values.unset,
|
||||
template: Union[str, object] = values.unset,
|
||||
prioritize_queue_order: Union[
|
||||
"WorkspaceInstance.QueueOrder", object
|
||||
] = values.unset,
|
||||
) -> WorkspaceInstance:
|
||||
"""
|
||||
Create the WorkspaceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workspace resource. It can be up to 64 characters long. For example: `Customer Support` or `2014 Election Campaign`.
|
||||
:param event_callback_url: The URL we should call when an event occurs. If provided, the Workspace will publish events to this URL, for example, to collect data for reporting. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:param events_filter: The list of Workspace events for which to call event_callback_url. For example, if `EventsFilter=task.created, task.canceled, worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:param multi_task_enabled: Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be created as multi-tasking. The default is `true`. Multi-tasking allows Workers to handle multiple Tasks simultaneously. When enabled (`true`), each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:param template: An available template name. Can be: `NONE` or `FIFO` and the default is `NONE`. Pre-configures the Workspace with the Workflow and Activities specified in the template. `NONE` will create a Workspace with only a set of default activities. `FIFO` will configure TaskRouter with a set of default activities and a single TaskQueue for first-in, first-out distribution, which can be useful when you are getting started with TaskRouter.
|
||||
:param prioritize_queue_order:
|
||||
|
||||
:returns: The created WorkspaceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EventCallbackUrl": event_callback_url,
|
||||
"EventsFilter": events_filter,
|
||||
"MultiTaskEnabled": multi_task_enabled,
|
||||
"Template": template,
|
||||
"PrioritizeQueueOrder": prioritize_queue_order,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkspaceInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
event_callback_url: Union[str, object] = values.unset,
|
||||
events_filter: Union[str, object] = values.unset,
|
||||
multi_task_enabled: Union[bool, object] = values.unset,
|
||||
template: Union[str, object] = values.unset,
|
||||
prioritize_queue_order: Union[
|
||||
"WorkspaceInstance.QueueOrder", object
|
||||
] = values.unset,
|
||||
) -> WorkspaceInstance:
|
||||
"""
|
||||
Asynchronously create the WorkspaceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workspace resource. It can be up to 64 characters long. For example: `Customer Support` or `2014 Election Campaign`.
|
||||
:param event_callback_url: The URL we should call when an event occurs. If provided, the Workspace will publish events to this URL, for example, to collect data for reporting. See [Workspace Events](https://www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio's [Webhooks (HTTP callbacks) Connection Overrides](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).
|
||||
:param events_filter: The list of Workspace events for which to call event_callback_url. For example, if `EventsFilter=task.created, task.canceled, worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.
|
||||
:param multi_task_enabled: Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. However, all workspaces should be created as multi-tasking. The default is `true`. Multi-tasking allows Workers to handle multiple Tasks simultaneously. When enabled (`true`), each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](https://www.twilio.com/docs/taskrouter/multitasking).
|
||||
:param template: An available template name. Can be: `NONE` or `FIFO` and the default is `NONE`. Pre-configures the Workspace with the Workflow and Activities specified in the template. `NONE` will create a Workspace with only a set of default activities. `FIFO` will configure TaskRouter with a set of default activities and a single TaskQueue for first-in, first-out distribution, which can be useful when you are getting started with TaskRouter.
|
||||
:param prioritize_queue_order:
|
||||
|
||||
:returns: The created WorkspaceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EventCallbackUrl": event_callback_url,
|
||||
"EventsFilter": events_filter,
|
||||
"MultiTaskEnabled": multi_task_enabled,
|
||||
"Template": template,
|
||||
"PrioritizeQueueOrder": prioritize_queue_order,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkspaceInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WorkspaceInstance]:
|
||||
"""
|
||||
Streams WorkspaceInstance 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 friendly_name: The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`.
|
||||
: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(friendly_name=friendly_name, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[WorkspaceInstance]:
|
||||
"""
|
||||
Asynchronously streams WorkspaceInstance 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 friendly_name: The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`.
|
||||
: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(
|
||||
friendly_name=friendly_name, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WorkspaceInstance]:
|
||||
"""
|
||||
Lists WorkspaceInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WorkspaceInstance]:
|
||||
"""
|
||||
Asynchronously lists WorkspaceInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: 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,
|
||||
) -> WorkspacePage:
|
||||
"""
|
||||
Retrieve a single page of WorkspaceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`.
|
||||
: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 WorkspaceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WorkspacePage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: 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,
|
||||
) -> WorkspacePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WorkspaceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the Workspace resources to read. For example `Customer Support` or `2014 Election Campaign`.
|
||||
: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 WorkspaceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return WorkspacePage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> WorkspacePage:
|
||||
"""
|
||||
Retrieve a specific page of WorkspaceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkspaceInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WorkspacePage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WorkspacePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WorkspaceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkspaceInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WorkspacePage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> WorkspaceContext:
|
||||
"""
|
||||
Constructs a WorkspaceContext
|
||||
|
||||
:param sid: The SID of the Workspace resource to update.
|
||||
"""
|
||||
return WorkspaceContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> WorkspaceContext:
|
||||
"""
|
||||
Constructs a WorkspaceContext
|
||||
|
||||
:param sid: The SID of the Workspace resource to update.
|
||||
"""
|
||||
return WorkspaceContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkspaceList>"
|
||||
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,653 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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 ActivityInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Activity resource.
|
||||
:ivar available: Whether the Worker is eligible to receive a Task when it occupies the Activity. A value of `true`, `1`, or `yes` indicates the Activity is available. All other values indicate that it is not. The value cannot be changed after the Activity is created.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the Activity resource.
|
||||
:ivar sid: The unique string that we created to identify the Activity resource.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Activity.
|
||||
:ivar url: The absolute URL of the Activity resource.
|
||||
:ivar links:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.available: Optional[bool] = payload.get("available")
|
||||
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.sid: Optional[str] = payload.get("sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ActivityContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ActivityContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ActivityContext for this ActivityInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ActivityContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ActivityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ActivityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ActivityInstance":
|
||||
"""
|
||||
Fetch the ActivityInstance
|
||||
|
||||
|
||||
:returns: The fetched ActivityInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ActivityInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ActivityInstance
|
||||
|
||||
|
||||
:returns: The fetched ActivityInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "ActivityInstance":
|
||||
"""
|
||||
Update the ActivityInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`.
|
||||
|
||||
:returns: The updated ActivityInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> "ActivityInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ActivityInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`.
|
||||
|
||||
:returns: The updated ActivityInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_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.Taskrouter.V1.ActivityInstance {}>".format(context)
|
||||
|
||||
|
||||
class ActivityContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the ActivityContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Activity resources to update.
|
||||
:param sid: The SID of the Activity resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Activities/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ActivityInstance
|
||||
|
||||
|
||||
: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 ActivityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ActivityInstance:
|
||||
"""
|
||||
Fetch the ActivityInstance
|
||||
|
||||
|
||||
:returns: The fetched ActivityInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ActivityInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ActivityInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ActivityInstance
|
||||
|
||||
|
||||
:returns: The fetched ActivityInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ActivityInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> ActivityInstance:
|
||||
"""
|
||||
Update the ActivityInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`.
|
||||
|
||||
:returns: The updated ActivityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ActivityInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, friendly_name: Union[str, object] = values.unset
|
||||
) -> ActivityInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ActivityInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`.
|
||||
|
||||
:returns: The updated ActivityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ActivityInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.ActivityContext {}>".format(context)
|
||||
|
||||
|
||||
class ActivityPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ActivityInstance:
|
||||
"""
|
||||
Build an instance of ActivityInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ActivityInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.ActivityPage>"
|
||||
|
||||
|
||||
class ActivityList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the ActivityList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Activity resources to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Activities".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, friendly_name: str, available: Union[bool, object] = values.unset
|
||||
) -> ActivityInstance:
|
||||
"""
|
||||
Create the ActivityInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`.
|
||||
:param available: Whether the Worker should be eligible to receive a Task when it occupies the Activity. A value of `true`, `1`, or `yes` specifies the Activity is available. All other values specify that it is not. The value cannot be changed after the Activity is created.
|
||||
|
||||
:returns: The created ActivityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Available": available,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ActivityInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, friendly_name: str, available: Union[bool, object] = values.unset
|
||||
) -> ActivityInstance:
|
||||
"""
|
||||
Asynchronously create the ActivityInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: `on-call`, `break`, and `email`.
|
||||
:param available: Whether the Worker should be eligible to receive a Task when it occupies the Activity. A value of `true`, `1`, or `yes` specifies the Activity is available. All other values specify that it is not. The value cannot be changed after the Activity is created.
|
||||
|
||||
:returns: The created ActivityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Available": available,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ActivityInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ActivityInstance]:
|
||||
"""
|
||||
Streams ActivityInstance 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 friendly_name: The `friendly_name` of the Activity resources to read.
|
||||
:param str available: Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
available=available,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ActivityInstance]:
|
||||
"""
|
||||
Asynchronously streams ActivityInstance 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 friendly_name: The `friendly_name` of the Activity resources to read.
|
||||
:param str available: Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
available=available,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ActivityInstance]:
|
||||
"""
|
||||
Lists ActivityInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the Activity resources to read.
|
||||
:param str available: Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
available=available,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ActivityInstance]:
|
||||
"""
|
||||
Asynchronously lists ActivityInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the Activity resources to read.
|
||||
:param str available: Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
available=available,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
available: 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,
|
||||
) -> ActivityPage:
|
||||
"""
|
||||
Retrieve a single page of ActivityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the Activity resources to read.
|
||||
:param available: Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable.
|
||||
: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 ActivityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Available": available,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ActivityPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
available: 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,
|
||||
) -> ActivityPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ActivityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the Activity resources to read.
|
||||
:param available: Whether return only Activity resources that are available or unavailable. A value of `true` returns only available activities. Values of '1' or `yes` also indicate `true`. All other values represent `false` and return activities that are unavailable.
|
||||
: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 ActivityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Available": available,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ActivityPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ActivityPage:
|
||||
"""
|
||||
Retrieve a specific page of ActivityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ActivityInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ActivityPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ActivityPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ActivityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ActivityInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ActivityPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ActivityContext:
|
||||
"""
|
||||
Constructs a ActivityContext
|
||||
|
||||
:param sid: The SID of the Activity resource to update.
|
||||
"""
|
||||
return ActivityContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ActivityContext:
|
||||
"""
|
||||
Constructs a ActivityContext
|
||||
|
||||
:param sid: The SID of the Activity resource to update.
|
||||
"""
|
||||
return ActivityContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.ActivityList>"
|
||||
@@ -0,0 +1,643 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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
|
||||
|
||||
|
||||
class EventInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Event resource.
|
||||
:ivar actor_sid: The SID of the resource that triggered the event.
|
||||
:ivar actor_type: The type of resource that triggered the event.
|
||||
:ivar actor_url: The absolute URL of the resource that triggered the event.
|
||||
:ivar description: A description of the event.
|
||||
:ivar event_data: Data about the event. For more information, see [Event types](https://www.twilio.com/docs/taskrouter/api/event#event-types).
|
||||
:ivar event_date: The time the event was sent, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar event_date_ms: The time the event was sent in milliseconds.
|
||||
:ivar event_type: The identifier for the event.
|
||||
:ivar resource_sid: The SID of the object the event is most relevant to, such as a TaskSid, ReservationSid, or a WorkerSid.
|
||||
:ivar resource_type: The type of object the event is most relevant to, such as a Task, Reservation, or a Worker).
|
||||
:ivar resource_url: The URL of the resource the event is most relevant to.
|
||||
:ivar sid: The unique string that we created to identify the Event resource.
|
||||
:ivar source: Where the Event originated.
|
||||
:ivar source_ip_address: The IP from which the Event originated.
|
||||
:ivar url: The absolute URL of the Event resource.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Event.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.actor_sid: Optional[str] = payload.get("actor_sid")
|
||||
self.actor_type: Optional[str] = payload.get("actor_type")
|
||||
self.actor_url: Optional[str] = payload.get("actor_url")
|
||||
self.description: Optional[str] = payload.get("description")
|
||||
self.event_data: Optional[Dict[str, object]] = payload.get("event_data")
|
||||
self.event_date: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("event_date")
|
||||
)
|
||||
self.event_date_ms: Optional[int] = payload.get("event_date_ms")
|
||||
self.event_type: Optional[str] = payload.get("event_type")
|
||||
self.resource_sid: Optional[str] = payload.get("resource_sid")
|
||||
self.resource_type: Optional[str] = payload.get("resource_type")
|
||||
self.resource_url: Optional[str] = payload.get("resource_url")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.source: Optional[str] = payload.get("source")
|
||||
self.source_ip_address: Optional[str] = payload.get("source_ip_address")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[EventContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "EventContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: EventContext for this EventInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = EventContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "EventInstance":
|
||||
"""
|
||||
Fetch the EventInstance
|
||||
|
||||
|
||||
:returns: The fetched EventInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "EventInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the EventInstance
|
||||
|
||||
|
||||
:returns: The fetched EventInstance
|
||||
"""
|
||||
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.Taskrouter.V1.EventInstance {}>".format(context)
|
||||
|
||||
|
||||
class EventContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the EventContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Event to fetch.
|
||||
:param sid: The SID of the Event resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Events/{sid}".format(**self._solution)
|
||||
|
||||
def fetch(self) -> EventInstance:
|
||||
"""
|
||||
Fetch the EventInstance
|
||||
|
||||
|
||||
:returns: The fetched EventInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return EventInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> EventInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the EventInstance
|
||||
|
||||
|
||||
:returns: The fetched EventInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return EventInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.EventContext {}>".format(context)
|
||||
|
||||
|
||||
class EventPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> EventInstance:
|
||||
"""
|
||||
Build an instance of EventInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return EventInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.EventPage>"
|
||||
|
||||
|
||||
class EventList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the EventList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Events to read. Returns only the Events that pertain to the specified Workspace.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Events".format(**self._solution)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
event_type: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
reservation_sid: Union[str, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_sid: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[EventInstance]:
|
||||
"""
|
||||
Streams EventInstance 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 datetime end_date: Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str event_type: The type of Events to read. Returns only Events of the type specified.
|
||||
:param int minutes: The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.
|
||||
:param str reservation_sid: The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.
|
||||
:param datetime start_date: Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.
|
||||
:param str task_sid: The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.
|
||||
:param str worker_sid: The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.
|
||||
:param str workflow_sid: The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.
|
||||
:param str task_channel: The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.
|
||||
:param str sid: The SID of the Event resource to read.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
event_type=event_type,
|
||||
minutes=minutes,
|
||||
reservation_sid=reservation_sid,
|
||||
start_date=start_date,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_sid=task_sid,
|
||||
worker_sid=worker_sid,
|
||||
workflow_sid=workflow_sid,
|
||||
task_channel=task_channel,
|
||||
sid=sid,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
event_type: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
reservation_sid: Union[str, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_sid: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[EventInstance]:
|
||||
"""
|
||||
Asynchronously streams EventInstance 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 datetime end_date: Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str event_type: The type of Events to read. Returns only Events of the type specified.
|
||||
:param int minutes: The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.
|
||||
:param str reservation_sid: The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.
|
||||
:param datetime start_date: Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.
|
||||
:param str task_sid: The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.
|
||||
:param str worker_sid: The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.
|
||||
:param str workflow_sid: The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.
|
||||
:param str task_channel: The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.
|
||||
:param str sid: The SID of the Event resource to read.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
event_type=event_type,
|
||||
minutes=minutes,
|
||||
reservation_sid=reservation_sid,
|
||||
start_date=start_date,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_sid=task_sid,
|
||||
worker_sid=worker_sid,
|
||||
workflow_sid=workflow_sid,
|
||||
task_channel=task_channel,
|
||||
sid=sid,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
event_type: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
reservation_sid: Union[str, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_sid: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EventInstance]:
|
||||
"""
|
||||
Lists EventInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end_date: Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str event_type: The type of Events to read. Returns only Events of the type specified.
|
||||
:param int minutes: The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.
|
||||
:param str reservation_sid: The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.
|
||||
:param datetime start_date: Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.
|
||||
:param str task_sid: The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.
|
||||
:param str worker_sid: The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.
|
||||
:param str workflow_sid: The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.
|
||||
:param str task_channel: The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.
|
||||
:param str sid: The SID of the Event resource to read.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
event_type=event_type,
|
||||
minutes=minutes,
|
||||
reservation_sid=reservation_sid,
|
||||
start_date=start_date,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_sid=task_sid,
|
||||
worker_sid=worker_sid,
|
||||
workflow_sid=workflow_sid,
|
||||
task_channel=task_channel,
|
||||
sid=sid,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
event_type: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
reservation_sid: Union[str, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_sid: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
sid: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EventInstance]:
|
||||
"""
|
||||
Asynchronously lists EventInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end_date: Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str event_type: The type of Events to read. Returns only Events of the type specified.
|
||||
:param int minutes: The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.
|
||||
:param str reservation_sid: The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.
|
||||
:param datetime start_date: Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.
|
||||
:param str task_sid: The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.
|
||||
:param str worker_sid: The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.
|
||||
:param str workflow_sid: The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.
|
||||
:param str task_channel: The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.
|
||||
:param str sid: The SID of the Event resource to read.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
event_type=event_type,
|
||||
minutes=minutes,
|
||||
reservation_sid=reservation_sid,
|
||||
start_date=start_date,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_sid=task_sid,
|
||||
worker_sid=worker_sid,
|
||||
workflow_sid=workflow_sid,
|
||||
task_channel=task_channel,
|
||||
sid=sid,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
event_type: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
reservation_sid: Union[str, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_sid: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
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,
|
||||
) -> EventPage:
|
||||
"""
|
||||
Retrieve a single page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end_date: Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param event_type: The type of Events to read. Returns only Events of the type specified.
|
||||
:param minutes: The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.
|
||||
:param reservation_sid: The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.
|
||||
:param start_date: Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted.
|
||||
:param task_queue_sid: The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.
|
||||
:param task_sid: The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.
|
||||
:param worker_sid: The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.
|
||||
:param workflow_sid: The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.
|
||||
:param task_channel: The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.
|
||||
:param sid: The SID of the Event resource to read.
|
||||
: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 EventInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"EventType": event_type,
|
||||
"Minutes": minutes,
|
||||
"ReservationSid": reservation_sid,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"TaskSid": task_sid,
|
||||
"WorkerSid": worker_sid,
|
||||
"WorkflowSid": workflow_sid,
|
||||
"TaskChannel": task_channel,
|
||||
"Sid": sid,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
event_type: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
reservation_sid: Union[str, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_sid: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
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,
|
||||
) -> EventPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end_date: Only include Events that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param event_type: The type of Events to read. Returns only Events of the type specified.
|
||||
:param minutes: The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.
|
||||
:param reservation_sid: The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.
|
||||
:param start_date: Only include Events from on or after this date and time, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Task Attributes for Events older than 30 days will be redacted.
|
||||
:param task_queue_sid: The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.
|
||||
:param task_sid: The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.
|
||||
:param worker_sid: The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.
|
||||
:param workflow_sid: The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.
|
||||
:param task_channel: The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.
|
||||
:param sid: The SID of the Event resource to read.
|
||||
: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 EventInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"EventType": event_type,
|
||||
"Minutes": minutes,
|
||||
"ReservationSid": reservation_sid,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"TaskSid": task_sid,
|
||||
"WorkerSid": worker_sid,
|
||||
"WorkflowSid": workflow_sid,
|
||||
"TaskChannel": task_channel,
|
||||
"Sid": sid,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> EventPage:
|
||||
"""
|
||||
Retrieve a specific page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> EventPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of EventInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EventInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return EventPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> EventContext:
|
||||
"""
|
||||
Constructs a EventContext
|
||||
|
||||
:param sid: The SID of the Event resource to fetch.
|
||||
"""
|
||||
return EventContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> EventContext:
|
||||
"""
|
||||
Constructs a EventContext
|
||||
|
||||
:param sid: The SID of the Event resource to fetch.
|
||||
"""
|
||||
return EventContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.EventList>"
|
||||
+969
@@ -0,0 +1,969 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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.taskrouter.v1.workspace.task.reservation import ReservationList
|
||||
|
||||
|
||||
class TaskInstance(InstanceResource):
|
||||
class Status(object):
|
||||
PENDING = "pending"
|
||||
RESERVED = "reserved"
|
||||
ASSIGNED = "assigned"
|
||||
CANCELED = "canceled"
|
||||
COMPLETED = "completed"
|
||||
WRAPPING = "wrapping"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Task resource.
|
||||
:ivar age: The number of seconds since the Task was created.
|
||||
:ivar assignment_status:
|
||||
:ivar attributes: The JSON string with custom attributes of the work. **Note** If this property has been assigned a value, it will only be displayed in FETCH action that returns a single resource. Otherwise, it will be null.
|
||||
:ivar addons: An object that contains the [addon](https://www.twilio.com/docs/taskrouter/marketplace) data for all installed addons.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar task_queue_entered_date: The date and time in GMT when the Task entered the TaskQueue, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar priority: The current priority score of the Task as assigned to a Worker by the workflow. Tasks with higher priority values will be assigned before Tasks with lower values.
|
||||
:ivar reason: The reason the Task was canceled or completed, if applicable.
|
||||
:ivar sid: The unique string that we created to identify the Task resource.
|
||||
:ivar task_queue_sid: The SID of the TaskQueue.
|
||||
:ivar task_queue_friendly_name: The friendly name of the TaskQueue.
|
||||
:ivar task_channel_sid: The SID of the TaskChannel.
|
||||
:ivar task_channel_unique_name: The unique name of the TaskChannel.
|
||||
:ivar timeout: The amount of time in seconds that the Task can live before being assigned.
|
||||
:ivar workflow_sid: The SID of the Workflow that is controlling the Task.
|
||||
:ivar workflow_friendly_name: The friendly name of the Workflow that is controlling the Task.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Task.
|
||||
:ivar url: The absolute URL of the Task resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
:ivar virtual_start_time: The date and time in GMT indicating the ordering for routing of the Task specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.age: Optional[int] = deserialize.integer(payload.get("age"))
|
||||
self.assignment_status: Optional["TaskInstance.Status"] = payload.get(
|
||||
"assignment_status"
|
||||
)
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.addons: Optional[str] = payload.get("addons")
|
||||
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_queue_entered_date: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("task_queue_entered_date")
|
||||
)
|
||||
self.priority: Optional[int] = deserialize.integer(payload.get("priority"))
|
||||
self.reason: Optional[str] = payload.get("reason")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.task_queue_sid: Optional[str] = payload.get("task_queue_sid")
|
||||
self.task_queue_friendly_name: Optional[str] = payload.get(
|
||||
"task_queue_friendly_name"
|
||||
)
|
||||
self.task_channel_sid: Optional[str] = payload.get("task_channel_sid")
|
||||
self.task_channel_unique_name: Optional[str] = payload.get(
|
||||
"task_channel_unique_name"
|
||||
)
|
||||
self.timeout: Optional[int] = deserialize.integer(payload.get("timeout"))
|
||||
self.workflow_sid: Optional[str] = payload.get("workflow_sid")
|
||||
self.workflow_friendly_name: Optional[str] = payload.get(
|
||||
"workflow_friendly_name"
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.virtual_start_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("virtual_start_time")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_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,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Deletes the TaskInstance
|
||||
|
||||
:param if_match: If provided, deletes this Task if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
if_match=if_match,
|
||||
)
|
||||
|
||||
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the TaskInstance
|
||||
|
||||
:param if_match: If provided, deletes this Task if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
if_match=if_match,
|
||||
)
|
||||
|
||||
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,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
assignment_status: Union["TaskInstance.Status", object] = values.unset,
|
||||
reason: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
virtual_start_time: Union[datetime, object] = values.unset,
|
||||
) -> "TaskInstance":
|
||||
"""
|
||||
Update the TaskInstance
|
||||
|
||||
:param if_match: If provided, applies this mutation if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
:param attributes: The JSON string that describes the custom attributes of the task.
|
||||
:param assignment_status:
|
||||
:param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.
|
||||
:param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).
|
||||
:param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future.
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
if_match=if_match,
|
||||
attributes=attributes,
|
||||
assignment_status=assignment_status,
|
||||
reason=reason,
|
||||
priority=priority,
|
||||
task_channel=task_channel,
|
||||
virtual_start_time=virtual_start_time,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
assignment_status: Union["TaskInstance.Status", object] = values.unset,
|
||||
reason: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
virtual_start_time: Union[datetime, object] = values.unset,
|
||||
) -> "TaskInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskInstance
|
||||
|
||||
:param if_match: If provided, applies this mutation if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
:param attributes: The JSON string that describes the custom attributes of the task.
|
||||
:param assignment_status:
|
||||
:param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.
|
||||
:param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).
|
||||
:param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future.
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
if_match=if_match,
|
||||
attributes=attributes,
|
||||
assignment_status=assignment_status,
|
||||
reason=reason,
|
||||
priority=priority,
|
||||
task_channel=task_channel,
|
||||
virtual_start_time=virtual_start_time,
|
||||
)
|
||||
|
||||
@property
|
||||
def reservations(self) -> ReservationList:
|
||||
"""
|
||||
Access the reservations
|
||||
"""
|
||||
return self._proxy.reservations
|
||||
|
||||
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.Taskrouter.V1.TaskInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the TaskContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Task to update.
|
||||
:param sid: The SID of the Task resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Tasks/{sid}".format(**self._solution)
|
||||
|
||||
self._reservations: Optional[ReservationList] = None
|
||||
|
||||
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Deletes the TaskInstance
|
||||
|
||||
:param if_match: If provided, deletes this Task if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the TaskInstance
|
||||
|
||||
:param if_match: If provided, deletes this Task if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
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,
|
||||
workspace_sid=self._solution["workspace_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,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
assignment_status: Union["TaskInstance.Status", object] = values.unset,
|
||||
reason: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
virtual_start_time: Union[datetime, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Update the TaskInstance
|
||||
|
||||
:param if_match: If provided, applies this mutation if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
:param attributes: The JSON string that describes the custom attributes of the task.
|
||||
:param assignment_status:
|
||||
:param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.
|
||||
:param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).
|
||||
:param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future.
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Attributes": attributes,
|
||||
"AssignmentStatus": assignment_status,
|
||||
"Reason": reason,
|
||||
"Priority": priority,
|
||||
"TaskChannel": task_channel,
|
||||
"VirtualStartTime": serialize.iso8601_datetime(virtual_start_time),
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
assignment_status: Union["TaskInstance.Status", object] = values.unset,
|
||||
reason: Union[str, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
virtual_start_time: Union[datetime, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskInstance
|
||||
|
||||
:param if_match: If provided, applies this mutation if (and only if) the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).
|
||||
:param attributes: The JSON string that describes the custom attributes of the task.
|
||||
:param assignment_status:
|
||||
:param reason: The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.
|
||||
:param priority: The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).
|
||||
:param task_channel: When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param virtual_start_time: The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future.
|
||||
|
||||
:returns: The updated TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Attributes": attributes,
|
||||
"AssignmentStatus": assignment_status,
|
||||
"Reason": reason,
|
||||
"Priority": priority,
|
||||
"TaskChannel": task_channel,
|
||||
"VirtualStartTime": serialize.iso8601_datetime(virtual_start_time),
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def reservations(self) -> ReservationList:
|
||||
"""
|
||||
Access the reservations
|
||||
"""
|
||||
if self._reservations is None:
|
||||
self._reservations = ReservationList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._reservations
|
||||
|
||||
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.Taskrouter.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, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskPage>"
|
||||
|
||||
|
||||
class TaskList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the TaskList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Tasks to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Tasks".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
timeout: Union[int, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
virtual_start_time: Union[datetime, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Create the TaskInstance
|
||||
|
||||
:param timeout: The amount of time in seconds the new task can live before being assigned. Can be up to a maximum of 2 weeks (1,209,600 seconds). The default value is 24 hours (86,400 seconds). On timeout, the `task.canceled` event will fire with description `Task TTL Exceeded`.
|
||||
:param priority: The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target. Value can be 0 to 2^31^ (2,147,483,647).
|
||||
:param task_channel: When MultiTasking is enabled, specify the TaskChannel by passing either its `unique_name` or `sid`. Default value is `default`.
|
||||
:param workflow_sid: The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional.
|
||||
:param attributes: A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`.
|
||||
:param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future.
|
||||
|
||||
:returns: The created TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Timeout": timeout,
|
||||
"Priority": priority,
|
||||
"TaskChannel": task_channel,
|
||||
"WorkflowSid": workflow_sid,
|
||||
"Attributes": attributes,
|
||||
"VirtualStartTime": serialize.iso8601_datetime(virtual_start_time),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
timeout: Union[int, object] = values.unset,
|
||||
priority: Union[int, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
virtual_start_time: Union[datetime, object] = values.unset,
|
||||
) -> TaskInstance:
|
||||
"""
|
||||
Asynchronously create the TaskInstance
|
||||
|
||||
:param timeout: The amount of time in seconds the new task can live before being assigned. Can be up to a maximum of 2 weeks (1,209,600 seconds). The default value is 24 hours (86,400 seconds). On timeout, the `task.canceled` event will fire with description `Task TTL Exceeded`.
|
||||
:param priority: The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target. Value can be 0 to 2^31^ (2,147,483,647).
|
||||
:param task_channel: When MultiTasking is enabled, specify the TaskChannel by passing either its `unique_name` or `sid`. Default value is `default`.
|
||||
:param workflow_sid: The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional.
|
||||
:param attributes: A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`.
|
||||
:param virtual_start_time: The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can't be in the future.
|
||||
|
||||
:returns: The created TaskInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Timeout": timeout,
|
||||
"Priority": priority,
|
||||
"TaskChannel": task_channel,
|
||||
"WorkflowSid": workflow_sid,
|
||||
"Attributes": attributes,
|
||||
"VirtualStartTime": serialize.iso8601_datetime(virtual_start_time),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
priority: Union[int, object] = values.unset,
|
||||
assignment_status: Union[List[str], object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
workflow_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
evaluate_task_attributes: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
has_addons: Union[bool, object] = values.unset,
|
||||
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 int priority: The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
|
||||
:param List[str] assignment_status: The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`.
|
||||
:param str workflow_sid: The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
|
||||
:param str workflow_name: The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.
|
||||
:param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
|
||||
:param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime.
|
||||
:param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons.
|
||||
: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(
|
||||
priority=priority,
|
||||
assignment_status=assignment_status,
|
||||
workflow_sid=workflow_sid,
|
||||
workflow_name=workflow_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_queue_name=task_queue_name,
|
||||
evaluate_task_attributes=evaluate_task_attributes,
|
||||
ordering=ordering,
|
||||
has_addons=has_addons,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
priority: Union[int, object] = values.unset,
|
||||
assignment_status: Union[List[str], object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
workflow_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
evaluate_task_attributes: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
has_addons: Union[bool, object] = values.unset,
|
||||
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 int priority: The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
|
||||
:param List[str] assignment_status: The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`.
|
||||
:param str workflow_sid: The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
|
||||
:param str workflow_name: The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.
|
||||
:param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
|
||||
:param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime.
|
||||
:param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons.
|
||||
: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(
|
||||
priority=priority,
|
||||
assignment_status=assignment_status,
|
||||
workflow_sid=workflow_sid,
|
||||
workflow_name=workflow_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_queue_name=task_queue_name,
|
||||
evaluate_task_attributes=evaluate_task_attributes,
|
||||
ordering=ordering,
|
||||
has_addons=has_addons,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
priority: Union[int, object] = values.unset,
|
||||
assignment_status: Union[List[str], object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
workflow_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
evaluate_task_attributes: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
has_addons: Union[bool, object] = values.unset,
|
||||
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 int priority: The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
|
||||
:param List[str] assignment_status: The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`.
|
||||
:param str workflow_sid: The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
|
||||
:param str workflow_name: The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.
|
||||
:param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
|
||||
:param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime.
|
||||
:param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons.
|
||||
: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(
|
||||
priority=priority,
|
||||
assignment_status=assignment_status,
|
||||
workflow_sid=workflow_sid,
|
||||
workflow_name=workflow_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_queue_name=task_queue_name,
|
||||
evaluate_task_attributes=evaluate_task_attributes,
|
||||
ordering=ordering,
|
||||
has_addons=has_addons,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
priority: Union[int, object] = values.unset,
|
||||
assignment_status: Union[List[str], object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
workflow_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
evaluate_task_attributes: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
has_addons: Union[bool, object] = values.unset,
|
||||
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 int priority: The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
|
||||
:param List[str] assignment_status: The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`.
|
||||
:param str workflow_sid: The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
|
||||
:param str workflow_name: The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
|
||||
:param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.
|
||||
:param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
|
||||
:param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime.
|
||||
:param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons.
|
||||
: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(
|
||||
priority=priority,
|
||||
assignment_status=assignment_status,
|
||||
workflow_sid=workflow_sid,
|
||||
workflow_name=workflow_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_queue_name=task_queue_name,
|
||||
evaluate_task_attributes=evaluate_task_attributes,
|
||||
ordering=ordering,
|
||||
has_addons=has_addons,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
priority: Union[int, object] = values.unset,
|
||||
assignment_status: Union[List[str], object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
workflow_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
evaluate_task_attributes: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
has_addons: Union[bool, object] = values.unset,
|
||||
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 priority: The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
|
||||
:param assignment_status: The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`.
|
||||
:param workflow_sid: The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
|
||||
:param workflow_name: The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
|
||||
:param task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.
|
||||
:param evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
|
||||
:param ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime.
|
||||
:param has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons.
|
||||
: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(
|
||||
{
|
||||
"Priority": priority,
|
||||
"AssignmentStatus": serialize.map(assignment_status, lambda e: e),
|
||||
"WorkflowSid": workflow_sid,
|
||||
"WorkflowName": workflow_name,
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"TaskQueueName": task_queue_name,
|
||||
"EvaluateTaskAttributes": evaluate_task_attributes,
|
||||
"Ordering": ordering,
|
||||
"HasAddons": has_addons,
|
||||
"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,
|
||||
priority: Union[int, object] = values.unset,
|
||||
assignment_status: Union[List[str], object] = values.unset,
|
||||
workflow_sid: Union[str, object] = values.unset,
|
||||
workflow_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
evaluate_task_attributes: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
has_addons: Union[bool, object] = values.unset,
|
||||
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 priority: The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
|
||||
:param assignment_status: The `assignment_status` of the Tasks you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`, `wrapping`, or `completed`. Returns all Tasks in the Workspace with the specified `assignment_status`.
|
||||
:param workflow_sid: The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
|
||||
:param workflow_name: The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
|
||||
:param task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.
|
||||
:param evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
|
||||
:param ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime.
|
||||
:param has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons.
|
||||
: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(
|
||||
{
|
||||
"Priority": priority,
|
||||
"AssignmentStatus": serialize.map(assignment_status, lambda e: e),
|
||||
"WorkflowSid": workflow_sid,
|
||||
"WorkflowName": workflow_name,
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"TaskQueueName": task_queue_name,
|
||||
"EvaluateTaskAttributes": evaluate_task_attributes,
|
||||
"Ordering": ordering,
|
||||
"HasAddons": has_addons,
|
||||
"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 SID of the Task resource to update.
|
||||
"""
|
||||
return TaskContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> TaskContext:
|
||||
"""
|
||||
Constructs a TaskContext
|
||||
|
||||
:param sid: The SID of the Task resource to update.
|
||||
"""
|
||||
return TaskContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+1294
File diff suppressed because it is too large
Load Diff
+643
@@ -0,0 +1,643 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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 TaskChannelInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Task Channel resource.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar sid: The unique string that we created to identify the Task Channel resource.
|
||||
:ivar unique_name: An application-defined string that uniquely identifies the Task Channel, such as `voice` or `sms`.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Task Channel.
|
||||
:ivar channel_optimized_routing: Whether the Task Channel will prioritize Workers that have been idle. When `true`, Workers that have been idle the longest are prioritized.
|
||||
:ivar url: The absolute URL of the Task Channel resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_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.sid: Optional[str] = payload.get("sid")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.channel_optimized_routing: Optional[bool] = payload.get(
|
||||
"channel_optimized_routing"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[TaskChannelContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskChannelContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskChannelContext for this TaskChannelInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskChannelContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the TaskChannelInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the TaskChannelInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "TaskChannelInstance":
|
||||
"""
|
||||
Fetch the TaskChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskChannelInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "TaskChannelInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskChannelInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
channel_optimized_routing: Union[bool, object] = values.unset,
|
||||
) -> "TaskChannelInstance":
|
||||
"""
|
||||
Update the TaskChannelInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.
|
||||
:param channel_optimized_routing: Whether the TaskChannel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
|
||||
|
||||
:returns: The updated TaskChannelInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
channel_optimized_routing=channel_optimized_routing,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
channel_optimized_routing: Union[bool, object] = values.unset,
|
||||
) -> "TaskChannelInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskChannelInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.
|
||||
:param channel_optimized_routing: Whether the TaskChannel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
|
||||
|
||||
:returns: The updated TaskChannelInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
channel_optimized_routing=channel_optimized_routing,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.TaskChannelInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskChannelContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the TaskChannelContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Task Channel to update.
|
||||
:param sid: The SID of the Task Channel resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskChannels/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the TaskChannelInstance
|
||||
|
||||
|
||||
: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 TaskChannelInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> TaskChannelInstance:
|
||||
"""
|
||||
Fetch the TaskChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskChannelInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> TaskChannelInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskChannelInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
channel_optimized_routing: Union[bool, object] = values.unset,
|
||||
) -> TaskChannelInstance:
|
||||
"""
|
||||
Update the TaskChannelInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.
|
||||
:param channel_optimized_routing: Whether the TaskChannel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
|
||||
|
||||
:returns: The updated TaskChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ChannelOptimizedRouting": channel_optimized_routing,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
channel_optimized_routing: Union[bool, object] = values.unset,
|
||||
) -> TaskChannelInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskChannelInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.
|
||||
:param channel_optimized_routing: Whether the TaskChannel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
|
||||
|
||||
:returns: The updated TaskChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ChannelOptimizedRouting": channel_optimized_routing,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.TaskChannelContext {}>".format(context)
|
||||
|
||||
|
||||
class TaskChannelPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TaskChannelInstance:
|
||||
"""
|
||||
Build an instance of TaskChannelInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TaskChannelInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskChannelPage>"
|
||||
|
||||
|
||||
class TaskChannelList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the TaskChannelList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Task Channel to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskChannels".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
unique_name: str,
|
||||
channel_optimized_routing: Union[bool, object] = values.unset,
|
||||
) -> TaskChannelInstance:
|
||||
"""
|
||||
Create the TaskChannelInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the Task Channel, such as `voice` or `sms`.
|
||||
:param channel_optimized_routing: Whether the Task Channel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
|
||||
|
||||
:returns: The created TaskChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
"ChannelOptimizedRouting": channel_optimized_routing,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskChannelInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
unique_name: str,
|
||||
channel_optimized_routing: Union[bool, object] = values.unset,
|
||||
) -> TaskChannelInstance:
|
||||
"""
|
||||
Asynchronously create the TaskChannelInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.
|
||||
:param unique_name: An application-defined string that uniquely identifies the Task Channel, such as `voice` or `sms`.
|
||||
:param channel_optimized_routing: Whether the Task Channel should prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
|
||||
|
||||
:returns: The created TaskChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"UniqueName": unique_name,
|
||||
"ChannelOptimizedRouting": channel_optimized_routing,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskChannelInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TaskChannelInstance]:
|
||||
"""
|
||||
Streams TaskChannelInstance 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[TaskChannelInstance]:
|
||||
"""
|
||||
Asynchronously streams TaskChannelInstance 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[TaskChannelInstance]:
|
||||
"""
|
||||
Lists TaskChannelInstance 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[TaskChannelInstance]:
|
||||
"""
|
||||
Asynchronously lists TaskChannelInstance 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,
|
||||
) -> TaskChannelPage:
|
||||
"""
|
||||
Retrieve a single page of TaskChannelInstance 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 TaskChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TaskChannelPage(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,
|
||||
) -> TaskChannelPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TaskChannelInstance 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 TaskChannelInstance
|
||||
"""
|
||||
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 TaskChannelPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TaskChannelPage:
|
||||
"""
|
||||
Retrieve a specific page of TaskChannelInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskChannelInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TaskChannelPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TaskChannelPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TaskChannelInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskChannelInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TaskChannelPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> TaskChannelContext:
|
||||
"""
|
||||
Constructs a TaskChannelContext
|
||||
|
||||
:param sid: The SID of the Task Channel resource to update.
|
||||
"""
|
||||
return TaskChannelContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> TaskChannelContext:
|
||||
"""
|
||||
Constructs a TaskChannelContext
|
||||
|
||||
:param sid: The SID of the Task Channel resource to update.
|
||||
"""
|
||||
return TaskChannelContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskChannelList>"
|
||||
+897
@@ -0,0 +1,897 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics import (
|
||||
TaskQueueCumulativeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics import (
|
||||
TaskQueueRealTimeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics import (
|
||||
TaskQueueStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics import (
|
||||
TaskQueuesStatisticsList,
|
||||
)
|
||||
|
||||
|
||||
class TaskQueueInstance(InstanceResource):
|
||||
class TaskOrder(object):
|
||||
FIFO = "FIFO"
|
||||
LIFO = "LIFO"
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource.
|
||||
:ivar assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned for them.
|
||||
:ivar assignment_activity_name: The name of the Activity to assign Workers when a task is assigned for them.
|
||||
: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.
|
||||
:ivar max_reserved_workers: The maximum number of Workers to reserve for the assignment of a task in the queue. Can be an integer between 1 and 50, inclusive and defaults to 1.
|
||||
:ivar reservation_activity_sid: The SID of the Activity to assign Workers once a task is reserved for them.
|
||||
:ivar reservation_activity_name: The name of the Activity to assign Workers once a task is reserved for them.
|
||||
:ivar sid: The unique string that we created to identify the TaskQueue resource.
|
||||
:ivar target_workers: A string describing the Worker selection criteria for any Tasks that enter the TaskQueue. For example `'\"language\" == \"spanish\"'` If no TargetWorkers parameter is provided, Tasks will wait in the TaskQueue until they are either deleted or moved to another TaskQueue. Additional examples on how to describing Worker selection criteria below. Defaults to 1==1.
|
||||
:ivar task_order:
|
||||
:ivar url: The absolute URL of the TaskQueue resource.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the TaskQueue.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assignment_activity_sid: Optional[str] = payload.get(
|
||||
"assignment_activity_sid"
|
||||
)
|
||||
self.assignment_activity_name: Optional[str] = payload.get(
|
||||
"assignment_activity_name"
|
||||
)
|
||||
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.max_reserved_workers: Optional[int] = deserialize.integer(
|
||||
payload.get("max_reserved_workers")
|
||||
)
|
||||
self.reservation_activity_sid: Optional[str] = payload.get(
|
||||
"reservation_activity_sid"
|
||||
)
|
||||
self.reservation_activity_name: Optional[str] = payload.get(
|
||||
"reservation_activity_name"
|
||||
)
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.target_workers: Optional[str] = payload.get("target_workers")
|
||||
self.task_order: Optional["TaskQueueInstance.TaskOrder"] = payload.get(
|
||||
"task_order"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[TaskQueueContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskQueueContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskQueueContext for this TaskQueueInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskQueueContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the TaskQueueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the TaskQueueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "TaskQueueInstance":
|
||||
"""
|
||||
Fetch the TaskQueueInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskQueueInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "TaskQueueInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskQueueInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers: Union[str, object] = values.unset,
|
||||
reservation_activity_sid: Union[str, object] = values.unset,
|
||||
assignment_activity_sid: Union[str, object] = values.unset,
|
||||
max_reserved_workers: Union[int, object] = values.unset,
|
||||
task_order: Union["TaskQueueInstance.TaskOrder", object] = values.unset,
|
||||
) -> "TaskQueueInstance":
|
||||
"""
|
||||
Update the TaskQueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`.
|
||||
:param target_workers: A string describing the Worker selection criteria for any Tasks that enter the TaskQueue. For example '\\\"language\\\" == \\\"spanish\\\"' If no TargetWorkers parameter is provided, Tasks will wait in the queue until they are either deleted or moved to another queue. Additional examples on how to describing Worker selection criteria below.
|
||||
:param reservation_activity_sid: The SID of the Activity to assign Workers when a task is reserved for them.
|
||||
:param assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned for them.
|
||||
:param max_reserved_workers: The maximum number of Workers to create reservations for the assignment of a task while in the queue. Maximum of 50.
|
||||
:param task_order:
|
||||
|
||||
:returns: The updated TaskQueueInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
target_workers=target_workers,
|
||||
reservation_activity_sid=reservation_activity_sid,
|
||||
assignment_activity_sid=assignment_activity_sid,
|
||||
max_reserved_workers=max_reserved_workers,
|
||||
task_order=task_order,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers: Union[str, object] = values.unset,
|
||||
reservation_activity_sid: Union[str, object] = values.unset,
|
||||
assignment_activity_sid: Union[str, object] = values.unset,
|
||||
max_reserved_workers: Union[int, object] = values.unset,
|
||||
task_order: Union["TaskQueueInstance.TaskOrder", object] = values.unset,
|
||||
) -> "TaskQueueInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskQueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`.
|
||||
:param target_workers: A string describing the Worker selection criteria for any Tasks that enter the TaskQueue. For example '\\\"language\\\" == \\\"spanish\\\"' If no TargetWorkers parameter is provided, Tasks will wait in the queue until they are either deleted or moved to another queue. Additional examples on how to describing Worker selection criteria below.
|
||||
:param reservation_activity_sid: The SID of the Activity to assign Workers when a task is reserved for them.
|
||||
:param assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned for them.
|
||||
:param max_reserved_workers: The maximum number of Workers to create reservations for the assignment of a task while in the queue. Maximum of 50.
|
||||
:param task_order:
|
||||
|
||||
:returns: The updated TaskQueueInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
target_workers=target_workers,
|
||||
reservation_activity_sid=reservation_activity_sid,
|
||||
assignment_activity_sid=assignment_activity_sid,
|
||||
max_reserved_workers=max_reserved_workers,
|
||||
task_order=task_order,
|
||||
)
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> TaskQueueCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
return self._proxy.cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> TaskQueueRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
return self._proxy.real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> TaskQueueStatisticsList:
|
||||
"""
|
||||
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.Taskrouter.V1.TaskQueueInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskQueueContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to update.
|
||||
:param sid: The SID of the TaskQueue resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskQueues/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._cumulative_statistics: Optional[TaskQueueCumulativeStatisticsList] = None
|
||||
self._real_time_statistics: Optional[TaskQueueRealTimeStatisticsList] = None
|
||||
self._statistics: Optional[TaskQueueStatisticsList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the TaskQueueInstance
|
||||
|
||||
|
||||
: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 TaskQueueInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> TaskQueueInstance:
|
||||
"""
|
||||
Fetch the TaskQueueInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskQueueInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskQueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> TaskQueueInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueInstance
|
||||
|
||||
|
||||
:returns: The fetched TaskQueueInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return TaskQueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers: Union[str, object] = values.unset,
|
||||
reservation_activity_sid: Union[str, object] = values.unset,
|
||||
assignment_activity_sid: Union[str, object] = values.unset,
|
||||
max_reserved_workers: Union[int, object] = values.unset,
|
||||
task_order: Union["TaskQueueInstance.TaskOrder", object] = values.unset,
|
||||
) -> TaskQueueInstance:
|
||||
"""
|
||||
Update the TaskQueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`.
|
||||
:param target_workers: A string describing the Worker selection criteria for any Tasks that enter the TaskQueue. For example '\\\"language\\\" == \\\"spanish\\\"' If no TargetWorkers parameter is provided, Tasks will wait in the queue until they are either deleted or moved to another queue. Additional examples on how to describing Worker selection criteria below.
|
||||
:param reservation_activity_sid: The SID of the Activity to assign Workers when a task is reserved for them.
|
||||
:param assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned for them.
|
||||
:param max_reserved_workers: The maximum number of Workers to create reservations for the assignment of a task while in the queue. Maximum of 50.
|
||||
:param task_order:
|
||||
|
||||
:returns: The updated TaskQueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"TargetWorkers": target_workers,
|
||||
"ReservationActivitySid": reservation_activity_sid,
|
||||
"AssignmentActivitySid": assignment_activity_sid,
|
||||
"MaxReservedWorkers": max_reserved_workers,
|
||||
"TaskOrder": task_order,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskQueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers: Union[str, object] = values.unset,
|
||||
reservation_activity_sid: Union[str, object] = values.unset,
|
||||
assignment_activity_sid: Union[str, object] = values.unset,
|
||||
max_reserved_workers: Union[int, object] = values.unset,
|
||||
task_order: Union["TaskQueueInstance.TaskOrder", object] = values.unset,
|
||||
) -> TaskQueueInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the TaskQueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`.
|
||||
:param target_workers: A string describing the Worker selection criteria for any Tasks that enter the TaskQueue. For example '\\\"language\\\" == \\\"spanish\\\"' If no TargetWorkers parameter is provided, Tasks will wait in the queue until they are either deleted or moved to another queue. Additional examples on how to describing Worker selection criteria below.
|
||||
:param reservation_activity_sid: The SID of the Activity to assign Workers when a task is reserved for them.
|
||||
:param assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned for them.
|
||||
:param max_reserved_workers: The maximum number of Workers to create reservations for the assignment of a task while in the queue. Maximum of 50.
|
||||
:param task_order:
|
||||
|
||||
:returns: The updated TaskQueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"TargetWorkers": target_workers,
|
||||
"ReservationActivitySid": reservation_activity_sid,
|
||||
"AssignmentActivitySid": assignment_activity_sid,
|
||||
"MaxReservedWorkers": max_reserved_workers,
|
||||
"TaskOrder": task_order,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskQueueInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> TaskQueueCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
if self._cumulative_statistics is None:
|
||||
self._cumulative_statistics = TaskQueueCumulativeStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> TaskQueueRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
if self._real_time_statistics is None:
|
||||
self._real_time_statistics = TaskQueueRealTimeStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> TaskQueueStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = TaskQueueStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_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.Taskrouter.V1.TaskQueueContext {}>".format(context)
|
||||
|
||||
|
||||
class TaskQueuePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TaskQueueInstance:
|
||||
"""
|
||||
Build an instance of TaskQueueInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TaskQueueInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueuePage>"
|
||||
|
||||
|
||||
class TaskQueueList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskQueues".format(**self._solution)
|
||||
|
||||
self._statistics: Optional[TaskQueuesStatisticsList] = None
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
target_workers: Union[str, object] = values.unset,
|
||||
max_reserved_workers: Union[int, object] = values.unset,
|
||||
task_order: Union["TaskQueueInstance.TaskOrder", object] = values.unset,
|
||||
reservation_activity_sid: Union[str, object] = values.unset,
|
||||
assignment_activity_sid: Union[str, object] = values.unset,
|
||||
) -> TaskQueueInstance:
|
||||
"""
|
||||
Create the TaskQueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`.
|
||||
:param target_workers: A string that describes the Worker selection criteria for any Tasks that enter the TaskQueue. For example, `'\\\"language\\\" == \\\"spanish\\\"'`. The default value is `1==1`. If this value is empty, Tasks will wait in the TaskQueue until they are deleted or moved to another TaskQueue. For more information about Worker selection, see [Describing Worker selection criteria](https://www.twilio.com/docs/taskrouter/api/taskqueues#target-workers).
|
||||
:param max_reserved_workers: The maximum number of Workers to reserve for the assignment of a Task in the queue. Can be an integer between 1 and 50, inclusive and defaults to 1.
|
||||
:param task_order:
|
||||
:param reservation_activity_sid: The SID of the Activity to assign Workers when a task is reserved for them.
|
||||
:param assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned to them.
|
||||
|
||||
:returns: The created TaskQueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"TargetWorkers": target_workers,
|
||||
"MaxReservedWorkers": max_reserved_workers,
|
||||
"TaskOrder": task_order,
|
||||
"ReservationActivitySid": reservation_activity_sid,
|
||||
"AssignmentActivitySid": assignment_activity_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskQueueInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
target_workers: Union[str, object] = values.unset,
|
||||
max_reserved_workers: Union[int, object] = values.unset,
|
||||
task_order: Union["TaskQueueInstance.TaskOrder", object] = values.unset,
|
||||
reservation_activity_sid: Union[str, object] = values.unset,
|
||||
assignment_activity_sid: Union[str, object] = values.unset,
|
||||
) -> TaskQueueInstance:
|
||||
"""
|
||||
Asynchronously create the TaskQueueInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the TaskQueue. For example `Support-Tier 1`, `Sales`, or `Escalation`.
|
||||
:param target_workers: A string that describes the Worker selection criteria for any Tasks that enter the TaskQueue. For example, `'\\\"language\\\" == \\\"spanish\\\"'`. The default value is `1==1`. If this value is empty, Tasks will wait in the TaskQueue until they are deleted or moved to another TaskQueue. For more information about Worker selection, see [Describing Worker selection criteria](https://www.twilio.com/docs/taskrouter/api/taskqueues#target-workers).
|
||||
:param max_reserved_workers: The maximum number of Workers to reserve for the assignment of a Task in the queue. Can be an integer between 1 and 50, inclusive and defaults to 1.
|
||||
:param task_order:
|
||||
:param reservation_activity_sid: The SID of the Activity to assign Workers when a task is reserved for them.
|
||||
:param assignment_activity_sid: The SID of the Activity to assign Workers when a task is assigned to them.
|
||||
|
||||
:returns: The created TaskQueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"TargetWorkers": target_workers,
|
||||
"MaxReservedWorkers": max_reserved_workers,
|
||||
"TaskOrder": task_order,
|
||||
"ReservationActivitySid": reservation_activity_sid,
|
||||
"AssignmentActivitySid": assignment_activity_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return TaskQueueInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
evaluate_worker_attributes: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TaskQueueInstance]:
|
||||
"""
|
||||
Streams TaskQueueInstance 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 friendly_name: The `friendly_name` of the TaskQueue resources to read.
|
||||
:param str evaluate_worker_attributes: The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter.
|
||||
:param str worker_sid: The SID of the Worker with the TaskQueue resources to read.
|
||||
:param str ordering: Sorting parameter for TaskQueues
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
evaluate_worker_attributes=evaluate_worker_attributes,
|
||||
worker_sid=worker_sid,
|
||||
ordering=ordering,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
evaluate_worker_attributes: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[TaskQueueInstance]:
|
||||
"""
|
||||
Asynchronously streams TaskQueueInstance 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 friendly_name: The `friendly_name` of the TaskQueue resources to read.
|
||||
:param str evaluate_worker_attributes: The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter.
|
||||
:param str worker_sid: The SID of the Worker with the TaskQueue resources to read.
|
||||
:param str ordering: Sorting parameter for TaskQueues
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
evaluate_worker_attributes=evaluate_worker_attributes,
|
||||
worker_sid=worker_sid,
|
||||
ordering=ordering,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
evaluate_worker_attributes: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TaskQueueInstance]:
|
||||
"""
|
||||
Lists TaskQueueInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the TaskQueue resources to read.
|
||||
:param str evaluate_worker_attributes: The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter.
|
||||
:param str worker_sid: The SID of the Worker with the TaskQueue resources to read.
|
||||
:param str ordering: Sorting parameter for TaskQueues
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
evaluate_worker_attributes=evaluate_worker_attributes,
|
||||
worker_sid=worker_sid,
|
||||
ordering=ordering,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
evaluate_worker_attributes: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TaskQueueInstance]:
|
||||
"""
|
||||
Asynchronously lists TaskQueueInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the TaskQueue resources to read.
|
||||
:param str evaluate_worker_attributes: The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter.
|
||||
:param str worker_sid: The SID of the Worker with the TaskQueue resources to read.
|
||||
:param str ordering: Sorting parameter for TaskQueues
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
evaluate_worker_attributes=evaluate_worker_attributes,
|
||||
worker_sid=worker_sid,
|
||||
ordering=ordering,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
evaluate_worker_attributes: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
ordering: 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,
|
||||
) -> TaskQueuePage:
|
||||
"""
|
||||
Retrieve a single page of TaskQueueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the TaskQueue resources to read.
|
||||
:param evaluate_worker_attributes: The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter.
|
||||
:param worker_sid: The SID of the Worker with the TaskQueue resources to read.
|
||||
:param ordering: Sorting parameter for TaskQueues
|
||||
: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 TaskQueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EvaluateWorkerAttributes": evaluate_worker_attributes,
|
||||
"WorkerSid": worker_sid,
|
||||
"Ordering": ordering,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TaskQueuePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
evaluate_worker_attributes: Union[str, object] = values.unset,
|
||||
worker_sid: Union[str, object] = values.unset,
|
||||
ordering: 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,
|
||||
) -> TaskQueuePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TaskQueueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the TaskQueue resources to read.
|
||||
:param evaluate_worker_attributes: The attributes of the Workers to read. Returns the TaskQueues with Workers that match the attributes specified in this parameter.
|
||||
:param worker_sid: The SID of the Worker with the TaskQueue resources to read.
|
||||
:param ordering: Sorting parameter for TaskQueues
|
||||
: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 TaskQueueInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EvaluateWorkerAttributes": evaluate_worker_attributes,
|
||||
"WorkerSid": worker_sid,
|
||||
"Ordering": ordering,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TaskQueuePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TaskQueuePage:
|
||||
"""
|
||||
Retrieve a specific page of TaskQueueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskQueueInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TaskQueuePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TaskQueuePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TaskQueueInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskQueueInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TaskQueuePage(self._version, response, self._solution)
|
||||
|
||||
@property
|
||||
def statistics(self) -> TaskQueuesStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = TaskQueuesStatisticsList(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
return self._statistics
|
||||
|
||||
def get(self, sid: str) -> TaskQueueContext:
|
||||
"""
|
||||
Constructs a TaskQueueContext
|
||||
|
||||
:param sid: The SID of the TaskQueue resource to update.
|
||||
"""
|
||||
return TaskQueueContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> TaskQueueContext:
|
||||
"""
|
||||
Constructs a TaskQueueContext
|
||||
|
||||
:param sid: The SID of the TaskQueue resource to update.
|
||||
"""
|
||||
return TaskQueueContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueueList>"
|
||||
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.
+366
@@ -0,0 +1,366 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, Union
|
||||
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
|
||||
|
||||
|
||||
class TaskQueueCumulativeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource.
|
||||
:ivar avg_task_acceptance_time: The average time in seconds between Task creation and acceptance.
|
||||
:ivar start_time: The beginning of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar end_time: The end of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar reservations_created: The total number of Reservations created for Tasks in the TaskQueue.
|
||||
:ivar reservations_accepted: The total number of Reservations accepted for Tasks in the TaskQueue.
|
||||
:ivar reservations_rejected: The total number of Reservations rejected for Tasks in the TaskQueue.
|
||||
:ivar reservations_timed_out: The total number of Reservations that timed out for Tasks in the TaskQueue.
|
||||
:ivar reservations_canceled: The total number of Reservations canceled for Tasks in the TaskQueue.
|
||||
:ivar reservations_rescinded: The total number of Reservations rescinded.
|
||||
:ivar split_by_wait_time: A list of objects that describe the number of Tasks canceled and reservations accepted above and below the thresholds specified in seconds.
|
||||
:ivar task_queue_sid: The SID of the TaskQueue from which these statistics were calculated.
|
||||
:ivar wait_duration_until_accepted: The wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks accepted while in the TaskQueue. Calculation is based on the time when the Tasks were created. For transfers, the wait duration is counted from the moment ***the Task was created***, and not from when the transfer was initiated.
|
||||
:ivar wait_duration_until_canceled: The wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks canceled while in the TaskQueue.
|
||||
:ivar wait_duration_in_queue_until_accepted: The relative wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks accepted while in the TaskQueue. Calculation is based on the time when the Tasks entered the TaskQueue.
|
||||
:ivar tasks_canceled: The total number of Tasks canceled in the TaskQueue.
|
||||
:ivar tasks_completed: The total number of Tasks completed in the TaskQueue.
|
||||
:ivar tasks_deleted: The total number of Tasks deleted in the TaskQueue.
|
||||
:ivar tasks_entered: The total number of Tasks entered into the TaskQueue.
|
||||
:ivar tasks_moved: The total number of Tasks that were moved from one queue to another.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the TaskQueue.
|
||||
:ivar url: The absolute URL of the TaskQueue statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
task_queue_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.avg_task_acceptance_time: Optional[int] = deserialize.integer(
|
||||
payload.get("avg_task_acceptance_time")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("end_time")
|
||||
)
|
||||
self.reservations_created: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_created")
|
||||
)
|
||||
self.reservations_accepted: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_accepted")
|
||||
)
|
||||
self.reservations_rejected: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rejected")
|
||||
)
|
||||
self.reservations_timed_out: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_timed_out")
|
||||
)
|
||||
self.reservations_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_canceled")
|
||||
)
|
||||
self.reservations_rescinded: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rescinded")
|
||||
)
|
||||
self.split_by_wait_time: Optional[Dict[str, object]] = payload.get(
|
||||
"split_by_wait_time"
|
||||
)
|
||||
self.task_queue_sid: Optional[str] = payload.get("task_queue_sid")
|
||||
self.wait_duration_until_accepted: Optional[Dict[str, object]] = payload.get(
|
||||
"wait_duration_until_accepted"
|
||||
)
|
||||
self.wait_duration_until_canceled: Optional[Dict[str, object]] = payload.get(
|
||||
"wait_duration_until_canceled"
|
||||
)
|
||||
self.wait_duration_in_queue_until_accepted: Optional[
|
||||
Dict[str, object]
|
||||
] = payload.get("wait_duration_in_queue_until_accepted")
|
||||
self.tasks_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_canceled")
|
||||
)
|
||||
self.tasks_completed: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_completed")
|
||||
)
|
||||
self.tasks_deleted: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_deleted")
|
||||
)
|
||||
self.tasks_entered: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_entered")
|
||||
)
|
||||
self.tasks_moved: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_moved")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
self._context: Optional[TaskQueueCumulativeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskQueueCumulativeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskQueueCumulativeStatisticsContext for this TaskQueueCumulativeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskQueueCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "TaskQueueCumulativeStatisticsInstance":
|
||||
"""
|
||||
Fetch the TaskQueueCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold.
|
||||
|
||||
:returns: The fetched TaskQueueCumulativeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "TaskQueueCumulativeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold.
|
||||
|
||||
:returns: The fetched TaskQueueCumulativeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.TaskQueueCumulativeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class TaskQueueCumulativeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueCumulativeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to fetch.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch statistics.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskQueues/{task_queue_sid}/CumulativeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> TaskQueueCumulativeStatisticsInstance:
|
||||
"""
|
||||
Fetch the TaskQueueCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold.
|
||||
|
||||
:returns: The fetched TaskQueueCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return TaskQueueCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> TaskQueueCumulativeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold.
|
||||
|
||||
:returns: The fetched TaskQueueCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return TaskQueueCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_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.Taskrouter.V1.TaskQueueCumulativeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class TaskQueueCumulativeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueCumulativeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to fetch.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch statistics.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
|
||||
def get(self) -> TaskQueueCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskQueueCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskQueueCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> TaskQueueCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskQueueCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskQueueCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueueCumulativeStatisticsList>"
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
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
|
||||
|
||||
|
||||
class TaskQueueRealTimeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource.
|
||||
:ivar activity_statistics: The number of current Workers by Activity.
|
||||
:ivar longest_task_waiting_age: The age of the longest waiting Task.
|
||||
:ivar longest_task_waiting_sid: The SID of the longest waiting Task.
|
||||
:ivar longest_relative_task_age_in_queue: The relative age in the TaskQueue for the longest waiting Task. Calculation is based on the time when the Task entered the TaskQueue.
|
||||
:ivar longest_relative_task_sid_in_queue: The Task SID of the Task waiting in the TaskQueue the longest. Calculation is based on the time when the Task entered the TaskQueue.
|
||||
:ivar task_queue_sid: The SID of the TaskQueue from which these statistics were calculated.
|
||||
:ivar tasks_by_priority: The number of Tasks by priority. For example: `{\"0\": \"10\", \"99\": \"5\"}` shows 10 Tasks at priority 0 and 5 at priority 99.
|
||||
:ivar tasks_by_status: The number of Tasks by their current status. For example: `{\"pending\": \"1\", \"reserved\": \"3\", \"assigned\": \"2\", \"completed\": \"5\"}`.
|
||||
:ivar total_available_workers: The total number of Workers available for Tasks in the TaskQueue.
|
||||
:ivar total_eligible_workers: The total number of Workers eligible for Tasks in the TaskQueue, independent of their Activity state.
|
||||
:ivar total_tasks: The total number of Tasks.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the TaskQueue.
|
||||
:ivar url: The absolute URL of the TaskQueue statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
task_queue_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.activity_statistics: Optional[List[object]] = payload.get(
|
||||
"activity_statistics"
|
||||
)
|
||||
self.longest_task_waiting_age: Optional[int] = deserialize.integer(
|
||||
payload.get("longest_task_waiting_age")
|
||||
)
|
||||
self.longest_task_waiting_sid: Optional[str] = payload.get(
|
||||
"longest_task_waiting_sid"
|
||||
)
|
||||
self.longest_relative_task_age_in_queue: Optional[int] = deserialize.integer(
|
||||
payload.get("longest_relative_task_age_in_queue")
|
||||
)
|
||||
self.longest_relative_task_sid_in_queue: Optional[str] = payload.get(
|
||||
"longest_relative_task_sid_in_queue"
|
||||
)
|
||||
self.task_queue_sid: Optional[str] = payload.get("task_queue_sid")
|
||||
self.tasks_by_priority: Optional[Dict[str, object]] = payload.get(
|
||||
"tasks_by_priority"
|
||||
)
|
||||
self.tasks_by_status: Optional[Dict[str, object]] = payload.get(
|
||||
"tasks_by_status"
|
||||
)
|
||||
self.total_available_workers: Optional[int] = deserialize.integer(
|
||||
payload.get("total_available_workers")
|
||||
)
|
||||
self.total_eligible_workers: Optional[int] = deserialize.integer(
|
||||
payload.get("total_eligible_workers")
|
||||
)
|
||||
self.total_tasks: Optional[int] = deserialize.integer(
|
||||
payload.get("total_tasks")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
self._context: Optional[TaskQueueRealTimeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskQueueRealTimeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskQueueRealTimeStatisticsContext for this TaskQueueRealTimeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskQueueRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "TaskQueueRealTimeStatisticsInstance":
|
||||
"""
|
||||
Fetch the TaskQueueRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: The TaskChannel for which to fetch statistics. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched TaskQueueRealTimeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "TaskQueueRealTimeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: The TaskChannel for which to fetch statistics. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched TaskQueueRealTimeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
task_channel=task_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.Taskrouter.V1.TaskQueueRealTimeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class TaskQueueRealTimeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueRealTimeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to fetch.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch statistics.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskQueues/{task_queue_sid}/RealTimeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> TaskQueueRealTimeStatisticsInstance:
|
||||
"""
|
||||
Fetch the TaskQueueRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: The TaskChannel for which to fetch statistics. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched TaskQueueRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return TaskQueueRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> TaskQueueRealTimeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: The TaskChannel for which to fetch statistics. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched TaskQueueRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return TaskQueueRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_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.Taskrouter.V1.TaskQueueRealTimeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class TaskQueueRealTimeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueRealTimeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to fetch.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch statistics.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
|
||||
def get(self) -> TaskQueueRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskQueueRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskQueueRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> TaskQueueRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskQueueRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskQueueRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueueRealTimeStatisticsList>"
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, 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 TaskQueueStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource.
|
||||
:ivar cumulative: An object that contains the cumulative statistics for the TaskQueue.
|
||||
:ivar realtime: An object that contains the real-time statistics for the TaskQueue.
|
||||
:ivar task_queue_sid: The SID of the TaskQueue from which these statistics were calculated.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the TaskQueue.
|
||||
:ivar url: The absolute URL of the TaskQueue statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
task_queue_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.cumulative: Optional[Dict[str, object]] = payload.get("cumulative")
|
||||
self.realtime: Optional[Dict[str, object]] = payload.get("realtime")
|
||||
self.task_queue_sid: Optional[str] = payload.get("task_queue_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
self._context: Optional[TaskQueueStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "TaskQueueStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: TaskQueueStatisticsContext for this TaskQueueStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = TaskQueueStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "TaskQueueStatisticsInstance":
|
||||
"""
|
||||
Fetch the TaskQueueStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate real-time and cumulative statistics for the specified TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
|
||||
:returns: The fetched TaskQueueStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "TaskQueueStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate real-time and cumulative statistics for the specified TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
|
||||
:returns: The fetched TaskQueueStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.TaskQueueStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskQueueStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to fetch.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch statistics.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Workspaces/{workspace_sid}/TaskQueues/{task_queue_sid}/Statistics".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> TaskQueueStatisticsInstance:
|
||||
"""
|
||||
Fetch the TaskQueueStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate real-time and cumulative statistics for the specified TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
|
||||
:returns: The fetched TaskQueueStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return TaskQueueStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> TaskQueueStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the TaskQueueStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate real-time and cumulative statistics for the specified TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
|
||||
:returns: The fetched TaskQueueStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return TaskQueueStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_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.Taskrouter.V1.TaskQueueStatisticsContext {}>".format(context)
|
||||
|
||||
|
||||
class TaskQueueStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueueStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueue to fetch.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch statistics.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"task_queue_sid": task_queue_sid,
|
||||
}
|
||||
|
||||
def get(self) -> TaskQueueStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskQueueStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskQueueStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> TaskQueueStatisticsContext:
|
||||
"""
|
||||
Constructs a TaskQueueStatisticsContext
|
||||
|
||||
"""
|
||||
return TaskQueueStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
task_queue_sid=self._solution["task_queue_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueueStatisticsList>"
|
||||
+399
@@ -0,0 +1,399 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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 serialize, values
|
||||
|
||||
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 TaskQueuesStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource.
|
||||
:ivar cumulative: An object that contains the cumulative statistics for the TaskQueues.
|
||||
:ivar realtime: An object that contains the real-time statistics for the TaskQueues.
|
||||
:ivar task_queue_sid: The SID of the TaskQueue from which these statistics were calculated.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the TaskQueues.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.cumulative: Optional[Dict[str, object]] = payload.get("cumulative")
|
||||
self.realtime: Optional[Dict[str, object]] = payload.get("realtime")
|
||||
self.task_queue_sid: Optional[str] = payload.get("task_queue_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_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.Taskrouter.V1.TaskQueuesStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class TaskQueuesStatisticsPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TaskQueuesStatisticsInstance:
|
||||
"""
|
||||
Build an instance of TaskQueuesStatisticsInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TaskQueuesStatisticsInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueuesStatisticsPage>"
|
||||
|
||||
|
||||
class TaskQueuesStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the TaskQueuesStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the TaskQueues to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/TaskQueues/Statistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TaskQueuesStatisticsInstance]:
|
||||
"""
|
||||
Streams TaskQueuesStatisticsInstance 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 datetime end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str friendly_name: The `friendly_name` of the TaskQueue statistics to read.
|
||||
:param int minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param datetime start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param str task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param str split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
friendly_name=friendly_name,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[TaskQueuesStatisticsInstance]:
|
||||
"""
|
||||
Asynchronously streams TaskQueuesStatisticsInstance 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 datetime end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str friendly_name: The `friendly_name` of the TaskQueue statistics to read.
|
||||
:param int minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param datetime start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param str task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param str split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
friendly_name=friendly_name,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TaskQueuesStatisticsInstance]:
|
||||
"""
|
||||
Lists TaskQueuesStatisticsInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str friendly_name: The `friendly_name` of the TaskQueue statistics to read.
|
||||
:param int minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param datetime start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param str task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param str split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
friendly_name=friendly_name,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TaskQueuesStatisticsInstance]:
|
||||
"""
|
||||
Asynchronously lists TaskQueuesStatisticsInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param str friendly_name: The `friendly_name` of the TaskQueue statistics to read.
|
||||
:param int minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param datetime start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param str task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param str split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
: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(
|
||||
end_date=end_date,
|
||||
friendly_name=friendly_name,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: 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,
|
||||
) -> TaskQueuesStatisticsPage:
|
||||
"""
|
||||
Retrieve a single page of TaskQueuesStatisticsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param friendly_name: The `friendly_name` of the TaskQueue statistics to read.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
: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 TaskQueuesStatisticsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"FriendlyName": friendly_name,
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TaskQueuesStatisticsPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: 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,
|
||||
) -> TaskQueuesStatisticsPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TaskQueuesStatisticsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param friendly_name: The `friendly_name` of the TaskQueue statistics to read.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default is 15 minutes.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.
|
||||
: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 TaskQueuesStatisticsInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"FriendlyName": friendly_name,
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TaskQueuesStatisticsPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> TaskQueuesStatisticsPage:
|
||||
"""
|
||||
Retrieve a specific page of TaskQueuesStatisticsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskQueuesStatisticsInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TaskQueuesStatisticsPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TaskQueuesStatisticsPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TaskQueuesStatisticsInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TaskQueuesStatisticsInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TaskQueuesStatisticsPage(self._version, response, self._solution)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.TaskQueuesStatisticsList>"
|
||||
+966
@@ -0,0 +1,966 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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.taskrouter.v1.workspace.worker.reservation import ReservationList
|
||||
from twilio.rest.taskrouter.v1.workspace.worker.worker_channel import WorkerChannelList
|
||||
from twilio.rest.taskrouter.v1.workspace.worker.worker_statistics import (
|
||||
WorkerStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics import (
|
||||
WorkersCumulativeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics import (
|
||||
WorkersRealTimeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.worker.workers_statistics import (
|
||||
WorkersStatisticsList,
|
||||
)
|
||||
|
||||
|
||||
class WorkerInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
|
||||
:ivar activity_name: The `friendly_name` of the Worker's current Activity.
|
||||
:ivar activity_sid: The SID of the Worker's current Activity.
|
||||
:ivar attributes: The JSON string that describes the Worker. For example: `{ \"email\": \"Bob@example.com\", \"phone\": \"+5095551234\" }`. **Note** If this property has been assigned a value, it will only be displayed in FETCH actions that return a single resource. Otherwise, this property will be null, even if it has a value. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker.
|
||||
:ivar available: Whether the Worker is available to perform tasks.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_status_changed: The date and time in GMT of the last change to the Worker's activity specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Used to calculate Workflow statistics.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource. Friendly names are case insensitive, and unique within the TaskRouter Workspace.
|
||||
:ivar sid: The unique string that we created to identify the Worker resource.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Worker.
|
||||
:ivar url: The absolute URL of the Worker resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.activity_name: Optional[str] = payload.get("activity_name")
|
||||
self.activity_sid: Optional[str] = payload.get("activity_sid")
|
||||
self.attributes: Optional[str] = payload.get("attributes")
|
||||
self.available: Optional[bool] = payload.get("available")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_status_changed: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_status_changed")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WorkerContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkerContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkerContext for this WorkerInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkerContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Deletes the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete(
|
||||
if_match=if_match,
|
||||
)
|
||||
|
||||
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async(
|
||||
if_match=if_match,
|
||||
)
|
||||
|
||||
def fetch(self) -> "WorkerInstance":
|
||||
"""
|
||||
Fetch the WorkerInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WorkerInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkerInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
reject_pending_reservations: Union[bool, object] = values.unset,
|
||||
) -> "WorkerInstance":
|
||||
"""
|
||||
Update the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
:param activity_sid: The SID of a valid Activity that will describe the Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information.
|
||||
:param attributes: The JSON string that describes the Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
|
||||
:param friendly_name: A descriptive string that you create to describe the Worker. It can be up to 64 characters long.
|
||||
:param reject_pending_reservations: Whether to reject the Worker's pending reservations. This option is only valid if the Worker's new [Activity](https://www.twilio.com/docs/taskrouter/api/activity) resource has its `availability` property set to `False`.
|
||||
|
||||
:returns: The updated WorkerInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
if_match=if_match,
|
||||
activity_sid=activity_sid,
|
||||
attributes=attributes,
|
||||
friendly_name=friendly_name,
|
||||
reject_pending_reservations=reject_pending_reservations,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
reject_pending_reservations: Union[bool, object] = values.unset,
|
||||
) -> "WorkerInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
:param activity_sid: The SID of a valid Activity that will describe the Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information.
|
||||
:param attributes: The JSON string that describes the Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
|
||||
:param friendly_name: A descriptive string that you create to describe the Worker. It can be up to 64 characters long.
|
||||
:param reject_pending_reservations: Whether to reject the Worker's pending reservations. This option is only valid if the Worker's new [Activity](https://www.twilio.com/docs/taskrouter/api/activity) resource has its `availability` property set to `False`.
|
||||
|
||||
:returns: The updated WorkerInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
if_match=if_match,
|
||||
activity_sid=activity_sid,
|
||||
attributes=attributes,
|
||||
friendly_name=friendly_name,
|
||||
reject_pending_reservations=reject_pending_reservations,
|
||||
)
|
||||
|
||||
@property
|
||||
def reservations(self) -> ReservationList:
|
||||
"""
|
||||
Access the reservations
|
||||
"""
|
||||
return self._proxy.reservations
|
||||
|
||||
@property
|
||||
def worker_channels(self) -> WorkerChannelList:
|
||||
"""
|
||||
Access the worker_channels
|
||||
"""
|
||||
return self._proxy.worker_channels
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkerStatisticsList:
|
||||
"""
|
||||
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.Taskrouter.V1.WorkerInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkerContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the WorkerContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Worker to update.
|
||||
:param sid: The SID of the Worker resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workers/{sid}".format(**self._solution)
|
||||
|
||||
self._reservations: Optional[ReservationList] = None
|
||||
self._worker_channels: Optional[WorkerChannelList] = None
|
||||
self._statistics: Optional[WorkerStatisticsList] = None
|
||||
|
||||
def delete(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Deletes the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
return self._version.delete(method="DELETE", uri=self._uri, headers=headers)
|
||||
|
||||
async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
return await self._version.delete_async(
|
||||
method="DELETE", uri=self._uri, headers=headers
|
||||
)
|
||||
|
||||
def fetch(self) -> WorkerInstance:
|
||||
"""
|
||||
Fetch the WorkerInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkerInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WorkerInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkerInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkerInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
reject_pending_reservations: Union[bool, object] = values.unset,
|
||||
) -> WorkerInstance:
|
||||
"""
|
||||
Update the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
:param activity_sid: The SID of a valid Activity that will describe the Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information.
|
||||
:param attributes: The JSON string that describes the Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
|
||||
:param friendly_name: A descriptive string that you create to describe the Worker. It can be up to 64 characters long.
|
||||
:param reject_pending_reservations: Whether to reject the Worker's pending reservations. This option is only valid if the Worker's new [Activity](https://www.twilio.com/docs/taskrouter/api/activity) resource has its `availability` property set to `False`.
|
||||
|
||||
:returns: The updated WorkerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"ActivitySid": activity_sid,
|
||||
"Attributes": attributes,
|
||||
"FriendlyName": friendly_name,
|
||||
"RejectPendingReservations": reject_pending_reservations,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return WorkerInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
if_match: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
reject_pending_reservations: Union[bool, object] = values.unset,
|
||||
) -> WorkerInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkerInstance
|
||||
|
||||
:param if_match: The If-Match HTTP request header
|
||||
:param activity_sid: The SID of a valid Activity that will describe the Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information.
|
||||
:param attributes: The JSON string that describes the Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
|
||||
:param friendly_name: A descriptive string that you create to describe the Worker. It can be up to 64 characters long.
|
||||
:param reject_pending_reservations: Whether to reject the Worker's pending reservations. This option is only valid if the Worker's new [Activity](https://www.twilio.com/docs/taskrouter/api/activity) resource has its `availability` property set to `False`.
|
||||
|
||||
:returns: The updated WorkerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"ActivitySid": activity_sid,
|
||||
"Attributes": attributes,
|
||||
"FriendlyName": friendly_name,
|
||||
"RejectPendingReservations": reject_pending_reservations,
|
||||
}
|
||||
)
|
||||
headers = values.of(
|
||||
{
|
||||
"If-Match": if_match,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST", uri=self._uri, data=data, headers=headers
|
||||
)
|
||||
|
||||
return WorkerInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def reservations(self) -> ReservationList:
|
||||
"""
|
||||
Access the reservations
|
||||
"""
|
||||
if self._reservations is None:
|
||||
self._reservations = ReservationList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._reservations
|
||||
|
||||
@property
|
||||
def worker_channels(self) -> WorkerChannelList:
|
||||
"""
|
||||
Access the worker_channels
|
||||
"""
|
||||
if self._worker_channels is None:
|
||||
self._worker_channels = WorkerChannelList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._worker_channels
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkerStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = WorkerStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_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.Taskrouter.V1.WorkerContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkerPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WorkerInstance:
|
||||
"""
|
||||
Build an instance of WorkerInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WorkerInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkerPage>"
|
||||
|
||||
|
||||
class WorkerList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkerList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workers to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workers".format(**self._solution)
|
||||
|
||||
self._cumulative_statistics: Optional[WorkersCumulativeStatisticsList] = None
|
||||
self._real_time_statistics: Optional[WorkersRealTimeStatisticsList] = None
|
||||
self._statistics: Optional[WorkersStatisticsList] = None
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
) -> WorkerInstance:
|
||||
"""
|
||||
Create the WorkerInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new Worker. It can be up to 64 characters long.
|
||||
:param activity_sid: The SID of a valid Activity that will describe the new Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information. If not provided, the new Worker's initial state is the `default_activity_sid` configured on the Workspace.
|
||||
:param attributes: A valid JSON string that describes the new Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
|
||||
|
||||
:returns: The created WorkerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ActivitySid": activity_sid,
|
||||
"Attributes": attributes,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkerInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
attributes: Union[str, object] = values.unset,
|
||||
) -> WorkerInstance:
|
||||
"""
|
||||
Asynchronously create the WorkerInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the new Worker. It can be up to 64 characters long.
|
||||
:param activity_sid: The SID of a valid Activity that will describe the new Worker's initial state. See [Activities](https://www.twilio.com/docs/taskrouter/api/activity) for more information. If not provided, the new Worker's initial state is the `default_activity_sid` configured on the Workspace.
|
||||
:param attributes: A valid JSON string that describes the new Worker. For example: `{ \\\"email\\\": \\\"Bob@example.com\\\", \\\"phone\\\": \\\"+5095551234\\\" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
|
||||
|
||||
:returns: The created WorkerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ActivitySid": activity_sid,
|
||||
"Attributes": attributes,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkerInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
activity_name: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers_expression: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WorkerInstance]:
|
||||
"""
|
||||
Streams WorkerInstance 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 activity_name: The `activity_name` of the Worker resources to read.
|
||||
:param str activity_sid: The `activity_sid` of the Worker resources to read.
|
||||
:param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available.
|
||||
:param str friendly_name: The `friendly_name` of the Worker resources to read.
|
||||
:param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name`
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str ordering: Sorting parameter for Workers
|
||||
: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(
|
||||
activity_name=activity_name,
|
||||
activity_sid=activity_sid,
|
||||
available=available,
|
||||
friendly_name=friendly_name,
|
||||
target_workers_expression=target_workers_expression,
|
||||
task_queue_name=task_queue_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
ordering=ordering,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
activity_name: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers_expression: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[WorkerInstance]:
|
||||
"""
|
||||
Asynchronously streams WorkerInstance 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 activity_name: The `activity_name` of the Worker resources to read.
|
||||
:param str activity_sid: The `activity_sid` of the Worker resources to read.
|
||||
:param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available.
|
||||
:param str friendly_name: The `friendly_name` of the Worker resources to read.
|
||||
:param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name`
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str ordering: Sorting parameter for Workers
|
||||
: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(
|
||||
activity_name=activity_name,
|
||||
activity_sid=activity_sid,
|
||||
available=available,
|
||||
friendly_name=friendly_name,
|
||||
target_workers_expression=target_workers_expression,
|
||||
task_queue_name=task_queue_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
ordering=ordering,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
activity_name: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers_expression: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WorkerInstance]:
|
||||
"""
|
||||
Lists WorkerInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str activity_name: The `activity_name` of the Worker resources to read.
|
||||
:param str activity_sid: The `activity_sid` of the Worker resources to read.
|
||||
:param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available.
|
||||
:param str friendly_name: The `friendly_name` of the Worker resources to read.
|
||||
:param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name`
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str ordering: Sorting parameter for Workers
|
||||
: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(
|
||||
activity_name=activity_name,
|
||||
activity_sid=activity_sid,
|
||||
available=available,
|
||||
friendly_name=friendly_name,
|
||||
target_workers_expression=target_workers_expression,
|
||||
task_queue_name=task_queue_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
ordering=ordering,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
activity_name: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers_expression: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
ordering: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WorkerInstance]:
|
||||
"""
|
||||
Asynchronously lists WorkerInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str activity_name: The `activity_name` of the Worker resources to read.
|
||||
:param str activity_sid: The `activity_sid` of the Worker resources to read.
|
||||
:param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available.
|
||||
:param str friendly_name: The `friendly_name` of the Worker resources to read.
|
||||
:param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name`
|
||||
:param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for.
|
||||
:param str ordering: Sorting parameter for Workers
|
||||
: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(
|
||||
activity_name=activity_name,
|
||||
activity_sid=activity_sid,
|
||||
available=available,
|
||||
friendly_name=friendly_name,
|
||||
target_workers_expression=target_workers_expression,
|
||||
task_queue_name=task_queue_name,
|
||||
task_queue_sid=task_queue_sid,
|
||||
ordering=ordering,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
activity_name: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers_expression: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
ordering: 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,
|
||||
) -> WorkerPage:
|
||||
"""
|
||||
Retrieve a single page of WorkerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param activity_name: The `activity_name` of the Worker resources to read.
|
||||
:param activity_sid: The `activity_sid` of the Worker resources to read.
|
||||
:param available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available.
|
||||
:param friendly_name: The `friendly_name` of the Worker resources to read.
|
||||
:param target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name`
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for.
|
||||
:param task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for.
|
||||
:param ordering: Sorting parameter for Workers
|
||||
: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 WorkerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"ActivityName": activity_name,
|
||||
"ActivitySid": activity_sid,
|
||||
"Available": available,
|
||||
"FriendlyName": friendly_name,
|
||||
"TargetWorkersExpression": target_workers_expression,
|
||||
"TaskQueueName": task_queue_name,
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"Ordering": ordering,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WorkerPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
activity_name: Union[str, object] = values.unset,
|
||||
activity_sid: Union[str, object] = values.unset,
|
||||
available: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
target_workers_expression: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
ordering: 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,
|
||||
) -> WorkerPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WorkerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param activity_name: The `activity_name` of the Worker resources to read.
|
||||
:param activity_sid: The `activity_sid` of the Worker resources to read.
|
||||
:param available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available.
|
||||
:param friendly_name: The `friendly_name` of the Worker resources to read.
|
||||
:param target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name`
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for.
|
||||
:param task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for.
|
||||
:param ordering: Sorting parameter for Workers
|
||||
: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 WorkerInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"ActivityName": activity_name,
|
||||
"ActivitySid": activity_sid,
|
||||
"Available": available,
|
||||
"FriendlyName": friendly_name,
|
||||
"TargetWorkersExpression": target_workers_expression,
|
||||
"TaskQueueName": task_queue_name,
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"Ordering": ordering,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return WorkerPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WorkerPage:
|
||||
"""
|
||||
Retrieve a specific page of WorkerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkerInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WorkerPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WorkerPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WorkerInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkerInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WorkerPage(self._version, response, self._solution)
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> WorkersCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
if self._cumulative_statistics is None:
|
||||
self._cumulative_statistics = WorkersCumulativeStatisticsList(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
return self._cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> WorkersRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
if self._real_time_statistics is None:
|
||||
self._real_time_statistics = WorkersRealTimeStatisticsList(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
return self._real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkersStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = WorkersStatisticsList(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
return self._statistics
|
||||
|
||||
def get(self, sid: str) -> WorkerContext:
|
||||
"""
|
||||
Constructs a WorkerContext
|
||||
|
||||
:param sid: The SID of the Worker resource to update.
|
||||
"""
|
||||
return WorkerContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WorkerContext:
|
||||
"""
|
||||
Constructs a WorkerContext
|
||||
|
||||
:param sid: The SID of the Worker resource to update.
|
||||
"""
|
||||
return WorkerContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkerList>"
|
||||
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.
+1237
File diff suppressed because it is too large
Load Diff
+571
@@ -0,0 +1,571 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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 WorkerChannelInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
|
||||
:ivar assigned_tasks: The total number of Tasks assigned to Worker for the TaskChannel type.
|
||||
:ivar available: Whether the Worker should receive Tasks of the TaskChannel type.
|
||||
:ivar available_capacity_percentage: The current percentage of capacity the TaskChannel has available. Can be a number between `0` and `100`. A value of `0` indicates that TaskChannel has no capacity available and a value of `100` means the Worker is available to receive any Tasks of this TaskChannel type.
|
||||
:ivar configured_capacity: The current configured capacity for the WorkerChannel. TaskRouter will not create any reservations after the assigned Tasks for the Worker reaches the value.
|
||||
: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 sid: The unique string that we created to identify the WorkerChannel resource.
|
||||
:ivar task_channel_sid: The SID of the TaskChannel.
|
||||
:ivar task_channel_unique_name: The unique name of the TaskChannel, such as `voice` or `sms`.
|
||||
:ivar worker_sid: The SID of the Worker that contains the WorkerChannel.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the WorkerChannel.
|
||||
:ivar url: The absolute URL of the WorkerChannel resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
worker_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assigned_tasks: Optional[int] = deserialize.integer(
|
||||
payload.get("assigned_tasks")
|
||||
)
|
||||
self.available: Optional[bool] = payload.get("available")
|
||||
self.available_capacity_percentage: Optional[int] = deserialize.integer(
|
||||
payload.get("available_capacity_percentage")
|
||||
)
|
||||
self.configured_capacity: Optional[int] = deserialize.integer(
|
||||
payload.get("configured_capacity")
|
||||
)
|
||||
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.sid: Optional[str] = payload.get("sid")
|
||||
self.task_channel_sid: Optional[str] = payload.get("task_channel_sid")
|
||||
self.task_channel_unique_name: Optional[str] = payload.get(
|
||||
"task_channel_unique_name"
|
||||
)
|
||||
self.worker_sid: Optional[str] = payload.get("worker_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"worker_sid": worker_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WorkerChannelContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkerChannelContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkerChannelContext for this WorkerChannelInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkerChannelContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "WorkerChannelInstance":
|
||||
"""
|
||||
Fetch the WorkerChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerChannelInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WorkerChannelInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkerChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerChannelInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
capacity: Union[int, object] = values.unset,
|
||||
available: Union[bool, object] = values.unset,
|
||||
) -> "WorkerChannelInstance":
|
||||
"""
|
||||
Update the WorkerChannelInstance
|
||||
|
||||
:param capacity: The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.
|
||||
:param available: Whether the WorkerChannel is available. Set to `false` to prevent the Worker from receiving any new Tasks of this TaskChannel type.
|
||||
|
||||
:returns: The updated WorkerChannelInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
capacity=capacity,
|
||||
available=available,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
capacity: Union[int, object] = values.unset,
|
||||
available: Union[bool, object] = values.unset,
|
||||
) -> "WorkerChannelInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkerChannelInstance
|
||||
|
||||
:param capacity: The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.
|
||||
:param available: Whether the WorkerChannel is available. Set to `false` to prevent the Worker from receiving any new Tasks of this TaskChannel type.
|
||||
|
||||
:returns: The updated WorkerChannelInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
capacity=capacity,
|
||||
available=available,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.WorkerChannelInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkerChannelContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, worker_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the WorkerChannelContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the WorkerChannel to update.
|
||||
:param worker_sid: The SID of the Worker with the WorkerChannel to update.
|
||||
:param sid: The SID of the WorkerChannel to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"worker_sid": worker_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Workspaces/{workspace_sid}/Workers/{worker_sid}/Channels/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(self) -> WorkerChannelInstance:
|
||||
"""
|
||||
Fetch the WorkerChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerChannelInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkerChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WorkerChannelInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkerChannelInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkerChannelInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkerChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
capacity: Union[int, object] = values.unset,
|
||||
available: Union[bool, object] = values.unset,
|
||||
) -> WorkerChannelInstance:
|
||||
"""
|
||||
Update the WorkerChannelInstance
|
||||
|
||||
:param capacity: The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.
|
||||
:param available: Whether the WorkerChannel is available. Set to `false` to prevent the Worker from receiving any new Tasks of this TaskChannel type.
|
||||
|
||||
:returns: The updated WorkerChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Capacity": capacity,
|
||||
"Available": available,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkerChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
capacity: Union[int, object] = values.unset,
|
||||
available: Union[bool, object] = values.unset,
|
||||
) -> WorkerChannelInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkerChannelInstance
|
||||
|
||||
:param capacity: The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.
|
||||
:param available: Whether the WorkerChannel is available. Set to `false` to prevent the Worker from receiving any new Tasks of this TaskChannel type.
|
||||
|
||||
:returns: The updated WorkerChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Capacity": capacity,
|
||||
"Available": available,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkerChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_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.Taskrouter.V1.WorkerChannelContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkerChannelPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WorkerChannelInstance:
|
||||
"""
|
||||
Build an instance of WorkerChannelInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WorkerChannelInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkerChannelPage>"
|
||||
|
||||
|
||||
class WorkerChannelList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, worker_sid: str):
|
||||
"""
|
||||
Initialize the WorkerChannelList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the WorkerChannels to read.
|
||||
:param worker_sid: The SID of the Worker with the WorkerChannels to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"worker_sid": worker_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workers/{worker_sid}/Channels".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WorkerChannelInstance]:
|
||||
"""
|
||||
Streams WorkerChannelInstance 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[WorkerChannelInstance]:
|
||||
"""
|
||||
Asynchronously streams WorkerChannelInstance 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[WorkerChannelInstance]:
|
||||
"""
|
||||
Lists WorkerChannelInstance 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[WorkerChannelInstance]:
|
||||
"""
|
||||
Asynchronously lists WorkerChannelInstance 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,
|
||||
) -> WorkerChannelPage:
|
||||
"""
|
||||
Retrieve a single page of WorkerChannelInstance 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 WorkerChannelInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WorkerChannelPage(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,
|
||||
) -> WorkerChannelPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WorkerChannelInstance 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 WorkerChannelInstance
|
||||
"""
|
||||
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 WorkerChannelPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WorkerChannelPage:
|
||||
"""
|
||||
Retrieve a specific page of WorkerChannelInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkerChannelInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WorkerChannelPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WorkerChannelPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WorkerChannelInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkerChannelInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WorkerChannelPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> WorkerChannelContext:
|
||||
"""
|
||||
Constructs a WorkerChannelContext
|
||||
|
||||
:param sid: The SID of the WorkerChannel to update.
|
||||
"""
|
||||
return WorkerChannelContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WorkerChannelContext:
|
||||
"""
|
||||
Constructs a WorkerChannelContext
|
||||
|
||||
:param sid: The SID of the WorkerChannel to update.
|
||||
"""
|
||||
return WorkerChannelContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkerChannelList>"
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, 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 WorkerStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
|
||||
:ivar cumulative: An object that contains the cumulative statistics for the Worker.
|
||||
:ivar worker_sid: The SID of the Worker that contains the WorkerChannel.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the WorkerChannel.
|
||||
:ivar url: The absolute URL of the WorkerChannel statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
worker_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.cumulative: Optional[Dict[str, object]] = payload.get("cumulative")
|
||||
self.worker_sid: Optional[str] = payload.get("worker_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"worker_sid": worker_sid,
|
||||
}
|
||||
self._context: Optional[WorkerStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkerStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkerStatisticsContext for this WorkerStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkerStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> "WorkerStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkerStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkerStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> "WorkerStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkerStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkerStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_channel=task_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.Taskrouter.V1.WorkerStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkerStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, worker_sid: str):
|
||||
"""
|
||||
Initialize the WorkerStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the WorkerChannel to fetch.
|
||||
:param worker_sid: The SID of the Worker with the WorkerChannel to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"worker_sid": worker_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Workspaces/{workspace_sid}/Workers/{worker_sid}/Statistics".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> WorkerStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkerStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkerStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkerStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> WorkerStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkerStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkerStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkerStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_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.Taskrouter.V1.WorkerStatisticsContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkerStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, worker_sid: str):
|
||||
"""
|
||||
Initialize the WorkerStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the WorkerChannel to fetch.
|
||||
:param worker_sid: The SID of the Worker with the WorkerChannel to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"worker_sid": worker_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkerStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkerStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkerStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkerStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkerStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkerStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
worker_sid=self._solution["worker_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkerStatisticsList>"
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
class WorkersCumulativeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
|
||||
:ivar start_time: The beginning of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar end_time: The end of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar activity_durations: The minimum, average, maximum, and total time (in seconds) that Workers spent in each Activity.
|
||||
:ivar reservations_created: The total number of Reservations that were created.
|
||||
:ivar reservations_accepted: The total number of Reservations that were accepted.
|
||||
:ivar reservations_rejected: The total number of Reservations that were rejected.
|
||||
:ivar reservations_timed_out: The total number of Reservations that were timed out.
|
||||
:ivar reservations_canceled: The total number of Reservations that were canceled.
|
||||
:ivar reservations_rescinded: The total number of Reservations that were rescinded.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Workers.
|
||||
:ivar url: The absolute URL of the Workers statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.start_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("end_time")
|
||||
)
|
||||
self.activity_durations: Optional[List[object]] = payload.get(
|
||||
"activity_durations"
|
||||
)
|
||||
self.reservations_created: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_created")
|
||||
)
|
||||
self.reservations_accepted: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_accepted")
|
||||
)
|
||||
self.reservations_rejected: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rejected")
|
||||
)
|
||||
self.reservations_timed_out: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_timed_out")
|
||||
)
|
||||
self.reservations_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_canceled")
|
||||
)
|
||||
self.reservations_rescinded: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rescinded")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._context: Optional[WorkersCumulativeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkersCumulativeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkersCumulativeStatisticsContext for this WorkersCumulativeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkersCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> "WorkersCumulativeStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkersCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersCumulativeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> "WorkersCumulativeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkersCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersCumulativeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_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.Taskrouter.V1.WorkersCumulativeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkersCumulativeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkersCumulativeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workers/CumulativeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> WorkersCumulativeStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkersCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkersCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> WorkersCumulativeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkersCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkersCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.WorkersCumulativeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkersCumulativeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkersCumulativeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the resource to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkersCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkersCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkersCumulativeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkersCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkersCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkersCumulativeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkersCumulativeStatisticsList>"
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
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
|
||||
|
||||
|
||||
class WorkersRealTimeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
|
||||
:ivar activity_statistics: The number of current Workers by Activity.
|
||||
:ivar total_workers: The total number of Workers.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Workers.
|
||||
:ivar url: The absolute URL of the Workers statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.activity_statistics: Optional[List[object]] = payload.get(
|
||||
"activity_statistics"
|
||||
)
|
||||
self.total_workers: Optional[int] = deserialize.integer(
|
||||
payload.get("total_workers")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._context: Optional[WorkersRealTimeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkersRealTimeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkersRealTimeStatisticsContext for this WorkersRealTimeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkersRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "WorkersRealTimeStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkersRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersRealTimeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "WorkersRealTimeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkersRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersRealTimeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
task_channel=task_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.Taskrouter.V1.WorkersRealTimeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkersRealTimeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkersRealTimeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workers/RealTimeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> WorkersRealTimeStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkersRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkersRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> WorkersRealTimeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkersRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkersRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.WorkersRealTimeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkersRealTimeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkersRealTimeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the resource to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkersRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkersRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkersRealTimeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkersRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkersRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkersRealTimeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkersRealTimeStatisticsList>"
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, 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 WorkersStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar realtime: An object that contains the real-time statistics for the Worker.
|
||||
:ivar cumulative: An object that contains the cumulative statistics for the Worker.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Worker.
|
||||
:ivar url: The absolute URL of the Worker statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.realtime: Optional[Dict[str, object]] = payload.get("realtime")
|
||||
self.cumulative: Optional[Dict[str, object]] = payload.get("cumulative")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._context: Optional[WorkersStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkersStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkersStatisticsContext for this WorkersStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkersStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> "WorkersStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkersStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch Worker statistics.
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue for which to fetch Worker statistics.
|
||||
:param friendly_name: Only include Workers with `friendly_name` values that match this parameter.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_queue_name=task_queue_name,
|
||||
friendly_name=friendly_name,
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> "WorkersStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkersStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch Worker statistics.
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue for which to fetch Worker statistics.
|
||||
:param friendly_name: Only include Workers with `friendly_name` values that match this parameter.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_queue_sid=task_queue_sid,
|
||||
task_queue_name=task_queue_name,
|
||||
friendly_name=friendly_name,
|
||||
task_channel=task_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.Taskrouter.V1.WorkersStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkersStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkersStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Worker to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workers/Statistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> WorkersStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkersStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch Worker statistics.
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue for which to fetch Worker statistics.
|
||||
:param friendly_name: Only include Workers with `friendly_name` values that match this parameter.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"TaskQueueName": task_queue_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkersStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_queue_sid: Union[str, object] = values.unset,
|
||||
task_queue_name: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
) -> WorkersStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkersStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_queue_sid: The SID of the TaskQueue for which to fetch Worker statistics.
|
||||
:param task_queue_name: The `friendly_name` of the TaskQueue for which to fetch Worker statistics.
|
||||
:param friendly_name: Only include Workers with `friendly_name` values that match this parameter.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkersStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskQueueSid": task_queue_sid,
|
||||
"TaskQueueName": task_queue_name,
|
||||
"FriendlyName": friendly_name,
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkersStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.WorkersStatisticsContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkersStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkersStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Worker to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkersStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkersStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkersStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkersStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkersStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkersStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkersStatisticsList>"
|
||||
+804
@@ -0,0 +1,804 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics import (
|
||||
WorkflowCumulativeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics import (
|
||||
WorkflowRealTimeStatisticsList,
|
||||
)
|
||||
from twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics import (
|
||||
WorkflowStatisticsList,
|
||||
)
|
||||
|
||||
|
||||
class WorkflowInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource.
|
||||
:ivar assignment_callback_url: The URL that we call when a task managed by the Workflow is assigned to a Worker. See Assignment Callback URL for more information.
|
||||
:ivar configuration: A JSON string that contains the Workflow's configuration. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
: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 document_content_type: The MIME type of the document.
|
||||
:ivar fallback_assignment_callback_url: The URL that we call when a call to the `assignment_callback_url` fails.
|
||||
:ivar friendly_name: The string that you assigned to describe the Workflow resource. For example, `Customer Support` or `2014 Election Campaign`.
|
||||
:ivar sid: The unique string that we created to identify the Workflow resource.
|
||||
:ivar task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Workflow.
|
||||
:ivar url: The absolute URL of the Workflow resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.assignment_callback_url: Optional[str] = payload.get(
|
||||
"assignment_callback_url"
|
||||
)
|
||||
self.configuration: Optional[str] = payload.get("configuration")
|
||||
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.document_content_type: Optional[str] = payload.get("document_content_type")
|
||||
self.fallback_assignment_callback_url: Optional[str] = payload.get(
|
||||
"fallback_assignment_callback_url"
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.task_reservation_timeout: Optional[int] = deserialize.integer(
|
||||
payload.get("task_reservation_timeout")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WorkflowContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkflowContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkflowContext for this WorkflowInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkflowContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WorkflowInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WorkflowInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "WorkflowInstance":
|
||||
"""
|
||||
Fetch the WorkflowInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkflowInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WorkflowInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkflowInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
assignment_callback_url: Union[str, object] = values.unset,
|
||||
fallback_assignment_callback_url: Union[str, object] = values.unset,
|
||||
configuration: Union[str, object] = values.unset,
|
||||
task_reservation_timeout: Union[int, object] = values.unset,
|
||||
re_evaluate_tasks: Union[str, object] = values.unset,
|
||||
) -> "WorkflowInstance":
|
||||
"""
|
||||
Update the WorkflowInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`.
|
||||
:param assignment_callback_url: The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.
|
||||
:param fallback_assignment_callback_url: The URL that we should call when a call to the `assignment_callback_url` fails.
|
||||
:param configuration: A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
:param task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
:param re_evaluate_tasks: Whether or not to re-evaluate Tasks. The default is `false`, which means Tasks in the Workflow will not be processed through the assignment loop again.
|
||||
|
||||
:returns: The updated WorkflowInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
assignment_callback_url=assignment_callback_url,
|
||||
fallback_assignment_callback_url=fallback_assignment_callback_url,
|
||||
configuration=configuration,
|
||||
task_reservation_timeout=task_reservation_timeout,
|
||||
re_evaluate_tasks=re_evaluate_tasks,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
assignment_callback_url: Union[str, object] = values.unset,
|
||||
fallback_assignment_callback_url: Union[str, object] = values.unset,
|
||||
configuration: Union[str, object] = values.unset,
|
||||
task_reservation_timeout: Union[int, object] = values.unset,
|
||||
re_evaluate_tasks: Union[str, object] = values.unset,
|
||||
) -> "WorkflowInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkflowInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`.
|
||||
:param assignment_callback_url: The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.
|
||||
:param fallback_assignment_callback_url: The URL that we should call when a call to the `assignment_callback_url` fails.
|
||||
:param configuration: A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
:param task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
:param re_evaluate_tasks: Whether or not to re-evaluate Tasks. The default is `false`, which means Tasks in the Workflow will not be processed through the assignment loop again.
|
||||
|
||||
:returns: The updated WorkflowInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
assignment_callback_url=assignment_callback_url,
|
||||
fallback_assignment_callback_url=fallback_assignment_callback_url,
|
||||
configuration=configuration,
|
||||
task_reservation_timeout=task_reservation_timeout,
|
||||
re_evaluate_tasks=re_evaluate_tasks,
|
||||
)
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> WorkflowCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
return self._proxy.cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> WorkflowRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
return self._proxy.real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkflowStatisticsList:
|
||||
"""
|
||||
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.Taskrouter.V1.WorkflowInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkflowContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the WorkflowContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workflow to update.
|
||||
:param sid: The SID of the Workflow resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workflows/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._cumulative_statistics: Optional[WorkflowCumulativeStatisticsList] = None
|
||||
self._real_time_statistics: Optional[WorkflowRealTimeStatisticsList] = None
|
||||
self._statistics: Optional[WorkflowStatisticsList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WorkflowInstance
|
||||
|
||||
|
||||
: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 WorkflowInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> WorkflowInstance:
|
||||
"""
|
||||
Fetch the WorkflowInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkflowInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkflowInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WorkflowInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowInstance
|
||||
|
||||
|
||||
:returns: The fetched WorkflowInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WorkflowInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
assignment_callback_url: Union[str, object] = values.unset,
|
||||
fallback_assignment_callback_url: Union[str, object] = values.unset,
|
||||
configuration: Union[str, object] = values.unset,
|
||||
task_reservation_timeout: Union[int, object] = values.unset,
|
||||
re_evaluate_tasks: Union[str, object] = values.unset,
|
||||
) -> WorkflowInstance:
|
||||
"""
|
||||
Update the WorkflowInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`.
|
||||
:param assignment_callback_url: The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.
|
||||
:param fallback_assignment_callback_url: The URL that we should call when a call to the `assignment_callback_url` fails.
|
||||
:param configuration: A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
:param task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
:param re_evaluate_tasks: Whether or not to re-evaluate Tasks. The default is `false`, which means Tasks in the Workflow will not be processed through the assignment loop again.
|
||||
|
||||
:returns: The updated WorkflowInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"AssignmentCallbackUrl": assignment_callback_url,
|
||||
"FallbackAssignmentCallbackUrl": fallback_assignment_callback_url,
|
||||
"Configuration": configuration,
|
||||
"TaskReservationTimeout": task_reservation_timeout,
|
||||
"ReEvaluateTasks": re_evaluate_tasks,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkflowInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
assignment_callback_url: Union[str, object] = values.unset,
|
||||
fallback_assignment_callback_url: Union[str, object] = values.unset,
|
||||
configuration: Union[str, object] = values.unset,
|
||||
task_reservation_timeout: Union[int, object] = values.unset,
|
||||
re_evaluate_tasks: Union[str, object] = values.unset,
|
||||
) -> WorkflowInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WorkflowInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`.
|
||||
:param assignment_callback_url: The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.
|
||||
:param fallback_assignment_callback_url: The URL that we should call when a call to the `assignment_callback_url` fails.
|
||||
:param configuration: A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
:param task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
:param re_evaluate_tasks: Whether or not to re-evaluate Tasks. The default is `false`, which means Tasks in the Workflow will not be processed through the assignment loop again.
|
||||
|
||||
:returns: The updated WorkflowInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"AssignmentCallbackUrl": assignment_callback_url,
|
||||
"FallbackAssignmentCallbackUrl": fallback_assignment_callback_url,
|
||||
"Configuration": configuration,
|
||||
"TaskReservationTimeout": task_reservation_timeout,
|
||||
"ReEvaluateTasks": re_evaluate_tasks,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkflowInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def cumulative_statistics(self) -> WorkflowCumulativeStatisticsList:
|
||||
"""
|
||||
Access the cumulative_statistics
|
||||
"""
|
||||
if self._cumulative_statistics is None:
|
||||
self._cumulative_statistics = WorkflowCumulativeStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._cumulative_statistics
|
||||
|
||||
@property
|
||||
def real_time_statistics(self) -> WorkflowRealTimeStatisticsList:
|
||||
"""
|
||||
Access the real_time_statistics
|
||||
"""
|
||||
if self._real_time_statistics is None:
|
||||
self._real_time_statistics = WorkflowRealTimeStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._real_time_statistics
|
||||
|
||||
@property
|
||||
def statistics(self) -> WorkflowStatisticsList:
|
||||
"""
|
||||
Access the statistics
|
||||
"""
|
||||
if self._statistics is None:
|
||||
self._statistics = WorkflowStatisticsList(
|
||||
self._version,
|
||||
self._solution["workspace_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.Taskrouter.V1.WorkflowContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkflowPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WorkflowInstance:
|
||||
"""
|
||||
Build an instance of WorkflowInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WorkflowInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkflowPage>"
|
||||
|
||||
|
||||
class WorkflowList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workflow to read.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workflows".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
configuration: str,
|
||||
assignment_callback_url: Union[str, object] = values.unset,
|
||||
fallback_assignment_callback_url: Union[str, object] = values.unset,
|
||||
task_reservation_timeout: Union[int, object] = values.unset,
|
||||
) -> WorkflowInstance:
|
||||
"""
|
||||
Create the WorkflowInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`.
|
||||
:param configuration: A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
:param assignment_callback_url: The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.
|
||||
:param fallback_assignment_callback_url: The URL that we should call when a call to the `assignment_callback_url` fails.
|
||||
:param task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
|
||||
:returns: The created WorkflowInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Configuration": configuration,
|
||||
"AssignmentCallbackUrl": assignment_callback_url,
|
||||
"FallbackAssignmentCallbackUrl": fallback_assignment_callback_url,
|
||||
"TaskReservationTimeout": task_reservation_timeout,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkflowInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
configuration: str,
|
||||
assignment_callback_url: Union[str, object] = values.unset,
|
||||
fallback_assignment_callback_url: Union[str, object] = values.unset,
|
||||
task_reservation_timeout: Union[int, object] = values.unset,
|
||||
) -> WorkflowInstance:
|
||||
"""
|
||||
Asynchronously create the WorkflowInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound Campaign`.
|
||||
:param configuration: A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](https://www.twilio.com/docs/taskrouter/workflow-configuration) for more information.
|
||||
:param assignment_callback_url: The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.
|
||||
:param fallback_assignment_callback_url: The URL that we should call when a call to the `assignment_callback_url` fails.
|
||||
:param task_reservation_timeout: How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to `86,400` (24 hours) and the default is `120`.
|
||||
|
||||
:returns: The created WorkflowInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Configuration": configuration,
|
||||
"AssignmentCallbackUrl": assignment_callback_url,
|
||||
"FallbackAssignmentCallbackUrl": fallback_assignment_callback_url,
|
||||
"TaskReservationTimeout": task_reservation_timeout,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WorkflowInstance(
|
||||
self._version, payload, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WorkflowInstance]:
|
||||
"""
|
||||
Streams WorkflowInstance 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 friendly_name: The `friendly_name` of the Workflow resources to read.
|
||||
: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(friendly_name=friendly_name, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[WorkflowInstance]:
|
||||
"""
|
||||
Asynchronously streams WorkflowInstance 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 friendly_name: The `friendly_name` of the Workflow resources to read.
|
||||
: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(
|
||||
friendly_name=friendly_name, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WorkflowInstance]:
|
||||
"""
|
||||
Lists WorkflowInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the Workflow resources to read.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WorkflowInstance]:
|
||||
"""
|
||||
Asynchronously lists WorkflowInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: The `friendly_name` of the Workflow resources to read.
|
||||
: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(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: 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,
|
||||
) -> WorkflowPage:
|
||||
"""
|
||||
Retrieve a single page of WorkflowInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the Workflow resources to read.
|
||||
: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 WorkflowInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WorkflowPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: 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,
|
||||
) -> WorkflowPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WorkflowInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The `friendly_name` of the Workflow resources to read.
|
||||
: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 WorkflowInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return WorkflowPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WorkflowPage:
|
||||
"""
|
||||
Retrieve a specific page of WorkflowInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkflowInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WorkflowPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WorkflowPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WorkflowInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WorkflowInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WorkflowPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> WorkflowContext:
|
||||
"""
|
||||
Constructs a WorkflowContext
|
||||
|
||||
:param sid: The SID of the Workflow resource to update.
|
||||
"""
|
||||
return WorkflowContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WorkflowContext:
|
||||
"""
|
||||
Constructs a WorkflowContext
|
||||
|
||||
:param sid: The SID of the Workflow resource to update.
|
||||
"""
|
||||
return WorkflowContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkflowList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+366
@@ -0,0 +1,366 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, Union
|
||||
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
|
||||
|
||||
|
||||
class WorkflowCumulativeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource.
|
||||
:ivar avg_task_acceptance_time: The average time in seconds between Task creation and acceptance.
|
||||
:ivar start_time: The beginning of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar end_time: The end of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar reservations_created: The total number of Reservations that were created for Workers.
|
||||
:ivar reservations_accepted: The total number of Reservations accepted by Workers.
|
||||
:ivar reservations_rejected: The total number of Reservations that were rejected.
|
||||
:ivar reservations_timed_out: The total number of Reservations that were timed out.
|
||||
:ivar reservations_canceled: The total number of Reservations that were canceled.
|
||||
:ivar reservations_rescinded: The total number of Reservations that were rescinded.
|
||||
:ivar split_by_wait_time: A list of objects that describe the number of Tasks canceled and reservations accepted above and below the thresholds specified in seconds.
|
||||
:ivar wait_duration_until_accepted: The wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks that were accepted.
|
||||
:ivar wait_duration_until_canceled: The wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks that were canceled.
|
||||
:ivar tasks_canceled: The total number of Tasks that were canceled.
|
||||
:ivar tasks_completed: The total number of Tasks that were completed.
|
||||
:ivar tasks_entered: The total number of Tasks that entered the Workflow.
|
||||
:ivar tasks_deleted: The total number of Tasks that were deleted.
|
||||
:ivar tasks_moved: The total number of Tasks that were moved from one queue to another.
|
||||
:ivar tasks_timed_out_in_workflow: The total number of Tasks that were timed out of their Workflows (and deleted).
|
||||
:ivar workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Workflow.
|
||||
:ivar url: The absolute URL of the Workflow statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
workflow_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.avg_task_acceptance_time: Optional[int] = deserialize.integer(
|
||||
payload.get("avg_task_acceptance_time")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("end_time")
|
||||
)
|
||||
self.reservations_created: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_created")
|
||||
)
|
||||
self.reservations_accepted: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_accepted")
|
||||
)
|
||||
self.reservations_rejected: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rejected")
|
||||
)
|
||||
self.reservations_timed_out: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_timed_out")
|
||||
)
|
||||
self.reservations_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_canceled")
|
||||
)
|
||||
self.reservations_rescinded: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rescinded")
|
||||
)
|
||||
self.split_by_wait_time: Optional[Dict[str, object]] = payload.get(
|
||||
"split_by_wait_time"
|
||||
)
|
||||
self.wait_duration_until_accepted: Optional[Dict[str, object]] = payload.get(
|
||||
"wait_duration_until_accepted"
|
||||
)
|
||||
self.wait_duration_until_canceled: Optional[Dict[str, object]] = payload.get(
|
||||
"wait_duration_until_canceled"
|
||||
)
|
||||
self.tasks_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_canceled")
|
||||
)
|
||||
self.tasks_completed: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_completed")
|
||||
)
|
||||
self.tasks_entered: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_entered")
|
||||
)
|
||||
self.tasks_deleted: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_deleted")
|
||||
)
|
||||
self.tasks_moved: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_moved")
|
||||
)
|
||||
self.tasks_timed_out_in_workflow: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_timed_out_in_workflow")
|
||||
)
|
||||
self.workflow_sid: Optional[str] = payload.get("workflow_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
self._context: Optional[WorkflowCumulativeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkflowCumulativeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkflowCumulativeStatisticsContext for this WorkflowCumulativeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkflowCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkflowCumulativeStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkflowCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkflowCumulativeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkflowCumulativeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkflowCumulativeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.WorkflowCumulativeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkflowCumulativeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, workflow_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowCumulativeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the resource to fetch.
|
||||
:param workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workflows/{workflow_sid}/CumulativeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkflowCumulativeStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkflowCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkflowCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkflowCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkflowCumulativeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkflowCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkflowCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_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.Taskrouter.V1.WorkflowCumulativeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkflowCumulativeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, workflow_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowCumulativeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the resource to fetch.
|
||||
:param workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkflowCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkflowCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkflowCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkflowCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkflowCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkflowCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkflowCumulativeStatisticsList>"
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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 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
|
||||
|
||||
|
||||
class WorkflowRealTimeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource.
|
||||
:ivar longest_task_waiting_age: The age of the longest waiting Task.
|
||||
:ivar longest_task_waiting_sid: The SID of the longest waiting Task.
|
||||
:ivar tasks_by_priority: The number of Tasks by priority. For example: `{\"0\": \"10\", \"99\": \"5\"}` shows 10 Tasks at priority 0 and 5 at priority 99.
|
||||
:ivar tasks_by_status: The number of Tasks by their current status. For example: `{\"pending\": \"1\", \"reserved\": \"3\", \"assigned\": \"2\", \"completed\": \"5\"}`.
|
||||
:ivar total_tasks: The total number of Tasks.
|
||||
:ivar workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified SID value.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Workflow.
|
||||
:ivar url: The absolute URL of the Workflow statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
workflow_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.longest_task_waiting_age: Optional[int] = deserialize.integer(
|
||||
payload.get("longest_task_waiting_age")
|
||||
)
|
||||
self.longest_task_waiting_sid: Optional[str] = payload.get(
|
||||
"longest_task_waiting_sid"
|
||||
)
|
||||
self.tasks_by_priority: Optional[Dict[str, object]] = payload.get(
|
||||
"tasks_by_priority"
|
||||
)
|
||||
self.tasks_by_status: Optional[Dict[str, object]] = payload.get(
|
||||
"tasks_by_status"
|
||||
)
|
||||
self.total_tasks: Optional[int] = deserialize.integer(
|
||||
payload.get("total_tasks")
|
||||
)
|
||||
self.workflow_sid: Optional[str] = payload.get("workflow_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
self._context: Optional[WorkflowRealTimeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkflowRealTimeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkflowRealTimeStatisticsContext for this WorkflowRealTimeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkflowRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "WorkflowRealTimeStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkflowRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkflowRealTimeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "WorkflowRealTimeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkflowRealTimeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
task_channel=task_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.Taskrouter.V1.WorkflowRealTimeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkflowRealTimeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, workflow_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowRealTimeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workflow to fetch.
|
||||
:param workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified SID value.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Workflows/{workflow_sid}/RealTimeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> WorkflowRealTimeStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkflowRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkflowRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkflowRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> WorkflowRealTimeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkflowRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkflowRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_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.Taskrouter.V1.WorkflowRealTimeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkflowRealTimeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, workflow_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowRealTimeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workflow to fetch.
|
||||
:param workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified SID value.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkflowRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkflowRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkflowRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkflowRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkflowRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkflowRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkflowRealTimeStatisticsList>"
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, 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 WorkflowStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource.
|
||||
:ivar cumulative: An object that contains the cumulative statistics for the Workflow.
|
||||
:ivar realtime: An object that contains the real-time statistics for the Workflow.
|
||||
:ivar workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified SID value.
|
||||
:ivar workspace_sid: The SID of the Workspace that contains the Workflow.
|
||||
:ivar url: The absolute URL of the Workflow statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
workspace_sid: str,
|
||||
workflow_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.cumulative: Optional[Dict[str, object]] = payload.get("cumulative")
|
||||
self.realtime: Optional[Dict[str, object]] = payload.get("realtime")
|
||||
self.workflow_sid: Optional[str] = payload.get("workflow_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
self._context: Optional[WorkflowStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkflowStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkflowStatisticsContext for this WorkflowStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkflowStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkflowStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkflowStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkflowStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkflowStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkflowStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.WorkflowStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkflowStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str, workflow_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workflow to fetch.
|
||||
:param workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified SID value.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Workspaces/{workspace_sid}/Workflows/{workflow_sid}/Statistics".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkflowStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkflowStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkflowStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkflowStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkflowStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkflowStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkflowStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkflowStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_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.Taskrouter.V1.WorkflowStatisticsContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkflowStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str, workflow_sid: str):
|
||||
"""
|
||||
Initialize the WorkflowStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace with the Workflow to fetch.
|
||||
:param workflow_sid: Returns the list of Tasks that are being controlled by the Workflow with the specified SID value.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
"workflow_sid": workflow_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkflowStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkflowStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkflowStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkflowStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkflowStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkflowStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
workflow_sid=self._solution["workflow_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkflowStatisticsList>"
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, Union
|
||||
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
|
||||
|
||||
|
||||
class WorkspaceCumulativeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workspace resource.
|
||||
:ivar avg_task_acceptance_time: The average time in seconds between Task creation and acceptance.
|
||||
:ivar start_time: The beginning of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar end_time: The end of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar reservations_created: The total number of Reservations that were created for Workers.
|
||||
:ivar reservations_accepted: The total number of Reservations accepted by Workers.
|
||||
:ivar reservations_rejected: The total number of Reservations that were rejected.
|
||||
:ivar reservations_timed_out: The total number of Reservations that were timed out.
|
||||
:ivar reservations_canceled: The total number of Reservations that were canceled.
|
||||
:ivar reservations_rescinded: The total number of Reservations that were rescinded.
|
||||
:ivar split_by_wait_time: A list of objects that describe the number of Tasks canceled and reservations accepted above and below the thresholds specified in seconds.
|
||||
:ivar wait_duration_until_accepted: The wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks that were accepted.
|
||||
:ivar wait_duration_until_canceled: The wait duration statistics (`avg`, `min`, `max`, `total`) for Tasks that were canceled.
|
||||
:ivar tasks_canceled: The total number of Tasks that were canceled.
|
||||
:ivar tasks_completed: The total number of Tasks that were completed.
|
||||
:ivar tasks_created: The total number of Tasks created.
|
||||
:ivar tasks_deleted: The total number of Tasks that were deleted.
|
||||
:ivar tasks_moved: The total number of Tasks that were moved from one queue to another.
|
||||
:ivar tasks_timed_out_in_workflow: The total number of Tasks that were timed out of their Workflows (and deleted).
|
||||
:ivar workspace_sid: The SID of the Workspace.
|
||||
:ivar url: The absolute URL of the Workspace statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.avg_task_acceptance_time: Optional[int] = deserialize.integer(
|
||||
payload.get("avg_task_acceptance_time")
|
||||
)
|
||||
self.start_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("start_time")
|
||||
)
|
||||
self.end_time: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("end_time")
|
||||
)
|
||||
self.reservations_created: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_created")
|
||||
)
|
||||
self.reservations_accepted: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_accepted")
|
||||
)
|
||||
self.reservations_rejected: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rejected")
|
||||
)
|
||||
self.reservations_timed_out: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_timed_out")
|
||||
)
|
||||
self.reservations_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_canceled")
|
||||
)
|
||||
self.reservations_rescinded: Optional[int] = deserialize.integer(
|
||||
payload.get("reservations_rescinded")
|
||||
)
|
||||
self.split_by_wait_time: Optional[Dict[str, object]] = payload.get(
|
||||
"split_by_wait_time"
|
||||
)
|
||||
self.wait_duration_until_accepted: Optional[Dict[str, object]] = payload.get(
|
||||
"wait_duration_until_accepted"
|
||||
)
|
||||
self.wait_duration_until_canceled: Optional[Dict[str, object]] = payload.get(
|
||||
"wait_duration_until_canceled"
|
||||
)
|
||||
self.tasks_canceled: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_canceled")
|
||||
)
|
||||
self.tasks_completed: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_completed")
|
||||
)
|
||||
self.tasks_created: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_created")
|
||||
)
|
||||
self.tasks_deleted: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_deleted")
|
||||
)
|
||||
self.tasks_moved: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_moved")
|
||||
)
|
||||
self.tasks_timed_out_in_workflow: Optional[int] = deserialize.integer(
|
||||
payload.get("tasks_timed_out_in_workflow")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._context: Optional[WorkspaceCumulativeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkspaceCumulativeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkspaceCumulativeStatisticsContext for this WorkspaceCumulativeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkspaceCumulativeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkspaceCumulativeStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkspaceCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkspaceCumulativeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkspaceCumulativeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkspaceCumulativeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
end_date=end_date,
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.WorkspaceCumulativeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkspaceCumulativeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceCumulativeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/CumulativeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkspaceCumulativeStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkspaceCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkspaceCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkspaceCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkspaceCumulativeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceCumulativeStatisticsInstance
|
||||
|
||||
:param end_date: Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param task_channel: Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
|
||||
|
||||
:returns: The fetched WorkspaceCumulativeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkspaceCumulativeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.WorkspaceCumulativeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkspaceCumulativeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceCumulativeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkspaceCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkspaceCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkspaceCumulativeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkspaceCumulativeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkspaceCumulativeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkspaceCumulativeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkspaceCumulativeStatisticsList>"
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
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
|
||||
|
||||
|
||||
class WorkspaceRealTimeStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workspace resource.
|
||||
:ivar activity_statistics: The number of current Workers by Activity.
|
||||
:ivar longest_task_waiting_age: The age of the longest waiting Task.
|
||||
:ivar longest_task_waiting_sid: The SID of the longest waiting Task.
|
||||
:ivar tasks_by_priority: The number of Tasks by priority. For example: `{\"0\": \"10\", \"99\": \"5\"}` shows 10 Tasks at priority 0 and 5 at priority 99.
|
||||
:ivar tasks_by_status: The number of Tasks by their current status. For example: `{\"pending\": \"1\", \"reserved\": \"3\", \"assigned\": \"2\", \"completed\": \"5\"}`.
|
||||
:ivar total_tasks: The total number of Tasks.
|
||||
:ivar total_workers: The total number of Workers in the Workspace.
|
||||
:ivar workspace_sid: The SID of the Workspace.
|
||||
:ivar url: The absolute URL of the Workspace statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.activity_statistics: Optional[List[object]] = payload.get(
|
||||
"activity_statistics"
|
||||
)
|
||||
self.longest_task_waiting_age: Optional[int] = deserialize.integer(
|
||||
payload.get("longest_task_waiting_age")
|
||||
)
|
||||
self.longest_task_waiting_sid: Optional[str] = payload.get(
|
||||
"longest_task_waiting_sid"
|
||||
)
|
||||
self.tasks_by_priority: Optional[Dict[str, object]] = payload.get(
|
||||
"tasks_by_priority"
|
||||
)
|
||||
self.tasks_by_status: Optional[Dict[str, object]] = payload.get(
|
||||
"tasks_by_status"
|
||||
)
|
||||
self.total_tasks: Optional[int] = deserialize.integer(
|
||||
payload.get("total_tasks")
|
||||
)
|
||||
self.total_workers: Optional[int] = deserialize.integer(
|
||||
payload.get("total_workers")
|
||||
)
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._context: Optional[WorkspaceRealTimeStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkspaceRealTimeStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkspaceRealTimeStatisticsContext for this WorkspaceRealTimeStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkspaceRealTimeStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "WorkspaceRealTimeStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkspaceRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkspaceRealTimeStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
task_channel=task_channel,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> "WorkspaceRealTimeStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkspaceRealTimeStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
task_channel=task_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.Taskrouter.V1.WorkspaceRealTimeStatisticsInstance {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkspaceRealTimeStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceRealTimeStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/RealTimeStatistics".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> WorkspaceRealTimeStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkspaceRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkspaceRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkspaceRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self, task_channel: Union[str, object] = values.unset
|
||||
) -> WorkspaceRealTimeStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceRealTimeStatisticsInstance
|
||||
|
||||
:param task_channel: Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
|
||||
:returns: The fetched WorkspaceRealTimeStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"TaskChannel": task_channel,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkspaceRealTimeStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.WorkspaceRealTimeStatisticsContext {}>".format(
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
class WorkspaceRealTimeStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceRealTimeStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkspaceRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkspaceRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkspaceRealTimeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkspaceRealTimeStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkspaceRealTimeStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkspaceRealTimeStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkspaceRealTimeStatisticsList>"
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Taskrouter
|
||||
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, 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 WorkspaceStatisticsInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar realtime: An object that contains the real-time statistics for the Workspace.
|
||||
:ivar cumulative: An object that contains the cumulative statistics for the Workspace.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workspace resource.
|
||||
:ivar workspace_sid: The SID of the Workspace.
|
||||
:ivar url: The absolute URL of the Workspace statistics resource.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.realtime: Optional[Dict[str, object]] = payload.get("realtime")
|
||||
self.cumulative: Optional[Dict[str, object]] = payload.get("cumulative")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.workspace_sid: Optional[str] = payload.get("workspace_sid")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._context: Optional[WorkspaceStatisticsContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WorkspaceStatisticsContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WorkspaceStatisticsContext for this WorkspaceStatisticsInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WorkspaceStatisticsContext(
|
||||
self._version,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkspaceStatisticsInstance":
|
||||
"""
|
||||
Fetch the WorkspaceStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkspaceStatisticsInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> "WorkspaceStatisticsInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkspaceStatisticsInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
minutes=minutes,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
task_channel=task_channel,
|
||||
split_by_wait_time=split_by_wait_time,
|
||||
)
|
||||
|
||||
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.Taskrouter.V1.WorkspaceStatisticsInstance {}>".format(context)
|
||||
|
||||
|
||||
class WorkspaceStatisticsContext(InstanceContext):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceStatisticsContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
self._uri = "/Workspaces/{workspace_sid}/Statistics".format(**self._solution)
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkspaceStatisticsInstance:
|
||||
"""
|
||||
Fetch the WorkspaceStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkspaceStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return WorkspaceStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
minutes: Union[int, object] = values.unset,
|
||||
start_date: Union[datetime, object] = values.unset,
|
||||
end_date: Union[datetime, object] = values.unset,
|
||||
task_channel: Union[str, object] = values.unset,
|
||||
split_by_wait_time: Union[str, object] = values.unset,
|
||||
) -> WorkspaceStatisticsInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WorkspaceStatisticsInstance
|
||||
|
||||
:param minutes: Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
|
||||
:param start_date: Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:param end_date: Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
|
||||
:param task_channel: Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
|
||||
:param split_by_wait_time: A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA.
|
||||
|
||||
:returns: The fetched WorkspaceStatisticsInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"Minutes": minutes,
|
||||
"StartDate": serialize.iso8601_datetime(start_date),
|
||||
"EndDate": serialize.iso8601_datetime(end_date),
|
||||
"TaskChannel": task_channel,
|
||||
"SplitByWaitTime": split_by_wait_time,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return WorkspaceStatisticsInstance(
|
||||
self._version,
|
||||
payload,
|
||||
workspace_sid=self._solution["workspace_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.Taskrouter.V1.WorkspaceStatisticsContext {}>".format(context)
|
||||
|
||||
|
||||
class WorkspaceStatisticsList(ListResource):
|
||||
def __init__(self, version: Version, workspace_sid: str):
|
||||
"""
|
||||
Initialize the WorkspaceStatisticsList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param workspace_sid: The SID of the Workspace to fetch.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"workspace_sid": workspace_sid,
|
||||
}
|
||||
|
||||
def get(self) -> WorkspaceStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkspaceStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkspaceStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __call__(self) -> WorkspaceStatisticsContext:
|
||||
"""
|
||||
Constructs a WorkspaceStatisticsContext
|
||||
|
||||
"""
|
||||
return WorkspaceStatisticsContext(
|
||||
self._version, workspace_sid=self._solution["workspace_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Taskrouter.V1.WorkspaceStatisticsList>"
|
||||
Reference in New Issue
Block a user