diff --git a/sdk/communication/azure-communication-jobrouter/CHANGELOG.md b/sdk/communication/azure-communication-jobrouter/CHANGELOG.md index dc809ca28855..f4f2475e7145 100644 --- a/sdk/communication/azure-communication-jobrouter/CHANGELOG.md +++ b/sdk/communication/azure-communication-jobrouter/CHANGELOG.md @@ -1,4 +1,16 @@ # Release History +## 1.1.0b1 (Unreleased) + +This is the beta release of Azure Communication Job Router Python SDK. For more information, please see the [README][read_me]. + +This is a Public Preview version, so breaking changes are possible in subsequent releases as we improve the product. To provide feedback, please submit an issue in our [Azure SDK for Python GitHub repo][issues]. + +### Features Added +- `JobRouterClient` + - `upsert_worker` + - keyword argument `max_concurrent_offers: Optional[int]` added. +- `RouterWorker` + - Add `max_concurrent_offers` ## 1.0.0 (2023-11-01) diff --git a/sdk/communication/azure-communication-jobrouter/assets.json b/sdk/communication/azure-communication-jobrouter/assets.json index 40ac9e3aa3a0..14ba37c8ddd8 100644 --- a/sdk/communication/azure-communication-jobrouter/assets.json +++ b/sdk/communication/azure-communication-jobrouter/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/communication/azure-communication-jobrouter", - "Tag": "python/communication/azure-communication-jobrouter_19ef87bca3" + "Tag": "python/communication/azure-communication-jobrouter_6a96a2c6e0" } diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_api_versions.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_api_versions.py index 833a315daa74..8f826623df34 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_api_versions.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_api_versions.py @@ -10,6 +10,7 @@ class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): V2022_07_18_PREVIEW = "2022-07-18-preview" V2023_11_01 = "2023-11-01" + V2024_01_18_PREVIEW = "2024-01-18-preview" -DEFAULT_VERSION = ApiVersion.V2023_11_01.value +DEFAULT_VERSION = ApiVersion.V2024_01_18_PREVIEW.value diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_client.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_client.py index ad6f17f9f863..24fcd9ae2500 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_client.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_client.py @@ -25,8 +25,9 @@ class JobRouterAdministrationClient( :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -100,8 +101,9 @@ class JobRouterClient(JobRouterClientOperationsMixin): # pylint: disable=client :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_configuration.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_configuration.py index bb7bf7ce4aa2..1e52a5a93939 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_configuration.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_configuration.py @@ -21,13 +21,14 @@ class JobRouterAdministrationClientConfiguration: # pylint: disable=too-many-in :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-01-18-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -58,13 +59,14 @@ class JobRouterClientConfiguration: # pylint: disable=too-many-instance-attribu :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-01-18-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_model_base.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_model_base.py index 19345476efdc..1ddc071517d6 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_model_base.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_model_base.py @@ -5,9 +5,9 @@ # license information. # -------------------------------------------------------------------------- # pylint: disable=protected-access, arguments-differ, signature-differs, broad-except -# pyright: reportGeneralTypeIssues=false import calendar +import decimal import functools import sys import logging @@ -15,9 +15,11 @@ import re import copy import typing -import email +import enum +import email.utils from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder +from typing_extensions import Self import isodate from azure.core.exceptions import DeserializationError from azure.core import CaseInsensitiveEnumMeta @@ -34,6 +36,7 @@ __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") def _timedelta_as_isostr(td: timedelta) -> str: @@ -144,6 +147,8 @@ def default(self, o): # pylint: disable=too-many-return-statements except TypeError: if isinstance(o, _Null): return None + if isinstance(o, decimal.Decimal): + return float(o) if isinstance(o, (bytes, bytearray)): return _serialize_bytes(o, self.format) try: @@ -239,7 +244,7 @@ def _deserialize_date(attr: typing.Union[str, date]) -> date: # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. if isinstance(attr, date): return attr - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore def _deserialize_time(attr: typing.Union[str, time]) -> time: @@ -275,6 +280,12 @@ def _deserialize_duration(attr): return isodate.parse_duration(attr) +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + _DESERIALIZE_MAPPING = { datetime: _deserialize_datetime, date: _deserialize_date, @@ -283,6 +294,7 @@ def _deserialize_duration(attr): bytearray: _deserialize_bytes, timedelta: _deserialize_duration, typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, } _DESERIALIZE_MAPPING_WITHFORMAT = { @@ -365,8 +377,12 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any: except KeyError: return default - @typing.overload # type: ignore - def pop(self, key: str) -> typing.Any: # pylint: disable=no-member + @typing.overload + def pop(self, key: str) -> typing.Any: + ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... @typing.overload @@ -387,8 +403,8 @@ def clear(self) -> None: def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: self._data.update(*args, **kwargs) - @typing.overload # type: ignore - def setdefault(self, key: str) -> typing.Any: + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload @@ -426,6 +442,10 @@ def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-m return tuple(_serialize(x, format) for x in o) if isinstance(o, (bytes, bytearray)): return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value try: # First try datetime.datetime return _serialize_datetime(o, format) @@ -450,7 +470,13 @@ def _get_rest_field( def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: - return _deserialize(rf._type, value) if (rf and rf._is_model) else _serialize(value, rf._format if rf else None) + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + return _serialize(value, rf._format) class Model(_MyMutableMapping): @@ -486,7 +512,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: def copy(self) -> "Model": return Model(self.__dict__) - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> "Model": # pylint: disable=unused-argument + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument # we know the last three classes in mro are going to be 'Model', 'dict', and 'object' mros = cls.__mro__[:-3][::-1] # ignore model, dict, and object parents, and reverse the mro order attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property @@ -528,7 +554,7 @@ def _deserialize(cls, data, exist_discriminators): return cls(data) discriminator = cls._get_discriminator(exist_discriminators) exist_discriminators.append(discriminator) - mapped_cls = cls.__mapping__.get(data.get(discriminator), cls) # pylint: disable=no-member + mapped_cls = cls.__mapping__.get(data.get(discriminator), cls) # pyright: ignore # pylint: disable=no-member if mapped_cls == cls: return cls(data) return mapped_cls._deserialize(data, exist_discriminators) # pylint: disable=protected-access @@ -545,9 +571,16 @@ def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing. if exclude_readonly: readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] for k, v in self.items(): - if exclude_readonly and k in readonly_props: # pyright: ignore[reportUnboundVariable] + if exclude_readonly and k in readonly_props: # pyright: ignore continue - result[k] = Model._as_dict_value(v, exclude_readonly=exclude_readonly) + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) return result @staticmethod @@ -555,7 +588,7 @@ def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: if v is None or isinstance(v, _Null): return None if isinstance(v, (list, tuple, set)): - return [Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v] + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) if isinstance(v, dict): return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v @@ -593,29 +626,22 @@ def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj return obj return _deserialize(model_deserializer, obj) - return functools.partial(_deserialize_model, annotation) + return functools.partial(_deserialize_model, annotation) # pyright: ignore except Exception: pass # is it a literal? try: - if sys.version_info >= (3, 8): - from typing import ( - Literal, - ) # pylint: disable=no-name-in-module, ungrouped-imports - else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - - if annotation.__origin__ == Literal: + if annotation.__origin__ is typing.Literal: # pyright: ignore return None except AttributeError: pass # is it optional? try: - if any(a for a in annotation.__args__ if a == type(None)): + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore ) def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): @@ -628,7 +654,13 @@ def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Calla pass if getattr(annotation, "__origin__", None) is typing.Union: - deserializers = [_get_deserialize_callable_from_annotation(arg, module, rf) for arg in annotation.__args__] + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in sorted( + annotation.__args__, key=lambda x: hasattr(x, "__name__") and x.__name__ == "str" # pyright: ignore + ) + ] def _deserialize_with_union(deserializers, obj): for deserializer in deserializers: @@ -641,32 +673,28 @@ def _deserialize_with_union(deserializers, obj): return functools.partial(_deserialize_with_union, deserializers) try: - if annotation._name == "Dict": - key_deserializer = _get_deserialize_callable_from_annotation(annotation.__args__[0], module, rf) - value_deserializer = _get_deserialize_callable_from_annotation(annotation.__args__[1], module, rf) + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) def _deserialize_dict( - key_deserializer: typing.Optional[typing.Callable], value_deserializer: typing.Optional[typing.Callable], obj: typing.Dict[typing.Any, typing.Any], ): if obj is None: return obj - return { - _deserialize(key_deserializer, k, module): _deserialize(value_deserializer, v, module) - for k, v in obj.items() - } + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} return functools.partial( _deserialize_dict, - key_deserializer, value_deserializer, ) except (AttributeError, IndexError): pass try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: - if len(annotation.__args__) > 1: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore def _deserialize_multiple_sequence( entry_deserializers: typing.List[typing.Optional[typing.Callable]], @@ -680,10 +708,13 @@ def _deserialize_multiple_sequence( ) entry_deserializers = [ - _get_deserialize_callable_from_annotation(dt, module, rf) for dt in annotation.__args__ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore ] return functools.partial(_deserialize_multiple_sequence, entry_deserializers) - deserializer = _get_deserialize_callable_from_annotation(annotation.__args__[0], module, rf) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) def _deserialize_sequence( deserializer: typing.Optional[typing.Callable], @@ -698,19 +729,21 @@ def _deserialize_sequence( pass def _deserialize_default( - annotation, - deserializer_from_mapping, + deserializer, obj, ): if obj is None: return obj try: - return _deserialize_with_callable(annotation, obj) + return _deserialize_with_callable(deserializer, obj) except Exception: pass - return _deserialize_with_callable(deserializer_from_mapping, obj) + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) - return functools.partial(_deserialize_default, annotation, get_deserializer(annotation, rf)) + return functools.partial(_deserialize_default, annotation) def _deserialize_with_callable( @@ -718,7 +751,7 @@ def _deserialize_with_callable( value: typing.Any, ): try: - if value is None: + if value is None or isinstance(value, _Null): return None if deserializer is None: return value @@ -746,7 +779,8 @@ def _deserialize( value = value.http_response.json() if rf is None and format: rf = _RestField(format=format) - deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) return _deserialize_with_callable(deserializer, value) @@ -760,6 +794,7 @@ def __init__( visibility: typing.Optional[typing.List[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, ): self._type = type self._rest_name_input = name @@ -769,6 +804,11 @@ def __init__( self._is_model = False self._default = default self._format = format + self._is_multipart_file_input = is_multipart_file_input + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] @property def _rest_name(self) -> str: @@ -814,8 +854,16 @@ def rest_field( visibility: typing.Optional[typing.List[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, ) -> typing.Any: - return _RestField(name=name, type=type, visibility=visibility, default=default, format=format) + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + ) def rest_discriminator( diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_operations.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_operations.py index ffd66a0b45d9..e8f589872451 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_operations.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -58,7 +58,7 @@ def build_job_router_administration_upsert_distribution_policy_request( # pylin _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +94,7 @@ def build_job_router_administration_get_distribution_policy_request( # pylint: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_job_router_administration_list_distribution_policies_request( # pylin _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -142,7 +142,7 @@ def build_job_router_administration_delete_distribution_policy_request( # pylin ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) # Construct URL _url = "/routing/distributionPolicies/{distributionPolicyId}" path_format_arguments = { @@ -169,7 +169,7 @@ def build_job_router_administration_upsert_classification_policy_request( # pyl _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -205,7 +205,7 @@ def build_job_router_administration_get_classification_policy_request( # pylint _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -231,7 +231,7 @@ def build_job_router_administration_list_classification_policies_request( # pyl _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,7 +253,7 @@ def build_job_router_administration_delete_classification_policy_request( # pyl ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) # Construct URL _url = "/routing/classificationPolicies/{classificationPolicyId}" path_format_arguments = { @@ -280,7 +280,7 @@ def build_job_router_administration_upsert_exception_policy_request( # pylint: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -316,7 +316,7 @@ def build_job_router_administration_get_exception_policy_request( # pylint: dis _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -342,7 +342,7 @@ def build_job_router_administration_list_exception_policies_request( # pylint: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -364,7 +364,7 @@ def build_job_router_administration_delete_exception_policy_request( # pylint: ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) # Construct URL _url = "/routing/exceptionPolicies/{exceptionPolicyId}" path_format_arguments = { @@ -391,7 +391,7 @@ def build_job_router_administration_upsert_queue_request( # pylint: disable=nam _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -427,7 +427,7 @@ def build_job_router_administration_get_queue_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -453,7 +453,7 @@ def build_job_router_administration_list_queues_request( # pylint: disable=name _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -475,7 +475,7 @@ def build_job_router_administration_delete_queue_request( # pylint: disable=nam ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) # Construct URL _url = "/routing/queues/{queueId}" path_format_arguments = { @@ -502,7 +502,7 @@ def build_job_router_upsert_job_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -536,7 +536,7 @@ def build_job_router_get_job_request(job_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -559,7 +559,7 @@ def build_job_router_get_job_request(job_id: str, **kwargs: Any) -> HttpRequest: def build_job_router_delete_job_request(job_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) # Construct URL _url = "/routing/jobs/{jobId}" path_format_arguments = { @@ -579,7 +579,7 @@ def build_job_router_reclassify_job_request(job_id: str, **kwargs: Any) -> HttpR _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -606,7 +606,7 @@ def build_job_router_cancel_job_request(job_id: str, **kwargs: Any) -> HttpReque _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -633,7 +633,7 @@ def build_job_router_complete_job_request(job_id: str, assignment_id: str, **kwa _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -661,7 +661,7 @@ def build_job_router_close_job_request(job_id: str, assignment_id: str, **kwargs _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -698,7 +698,7 @@ def build_job_router_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -735,7 +735,7 @@ def build_job_router_get_queue_position_request( # pylint: disable=name-too-lon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -760,7 +760,7 @@ def build_job_router_unassign_job_request(job_id: str, assignment_id: str, **kwa _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -789,7 +789,7 @@ def build_job_router_accept_job_offer_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -817,7 +817,7 @@ def build_job_router_decline_job_offer_request( # pylint: disable=name-too-long _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -846,7 +846,7 @@ def build_job_router_get_queue_statistics_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -878,7 +878,7 @@ def build_job_router_upsert_worker_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -912,7 +912,7 @@ def build_job_router_get_worker_request(worker_id: str, **kwargs: Any) -> HttpRe _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -935,7 +935,7 @@ def build_job_router_get_worker_request(worker_id: str, **kwargs: Any) -> HttpRe def build_job_router_delete_worker_request(worker_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) # Construct URL _url = "/routing/workers/{workerId}" path_format_arguments = { @@ -962,7 +962,7 @@ def build_job_router_list_workers_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-18-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1002,6 +1002,7 @@ def upsert_distribution_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -1021,11 +1022,246 @@ def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ @overload @@ -1040,6 +1276,7 @@ def upsert_distribution_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -1059,18 +1296,171 @@ def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ @overload def upsert_distribution_policy( self, distribution_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1078,6 +1468,7 @@ def upsert_distribution_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -1085,7 +1476,7 @@ def upsert_distribution_policy( :param distribution_policy_id: Id of a distribution policy. Required. :type distribution_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1097,24 +1488,178 @@ def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ @distributed_trace def upsert_distribution_policy( self, distribution_policy_id: str, - resource: Union[_models.DistributionPolicy, JSON, IO], + resource: Union[_models.DistributionPolicy, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -1122,8 +1667,8 @@ def upsert_distribution_policy( :param distribution_policy_id: Id of a distribution policy. Required. :type distribution_policy_id: str :param resource: The resource instance. Is one of the following types: DistributionPolicy, - JSON, IO Required. - :type resource: ~azure.communication.jobrouter.models.DistributionPolicy or JSON or IO + JSON, IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.DistributionPolicy or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1132,13 +1677,246 @@ def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ error_map = { 401: ClientAuthenticationError, @@ -1222,17 +2000,100 @@ def upsert_distribution_policy( @distributed_trace def get_distribution_policy(self, distribution_policy_id: str, **kwargs: Any) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Retrieves an existing distribution policy by Id. Retrieves an existing distribution policy by Id. :param distribution_policy_id: Id of a distribution policy. Required. :type distribution_policy_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ error_map = { 401: ClientAuthenticationError, @@ -1285,8 +2146,10 @@ def get_distribution_policy(self, distribution_policy_id: str, **kwargs: Any) -> return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_distribution_policies(self, **kwargs: Any) -> ItemPaged["_models.DistributionPolicy"]: + # pylint: disable=line-too-long """Retrieves existing distribution policies. Retrieves existing distribution policies. @@ -1294,6 +2157,90 @@ def list_distribution_policies(self, **kwargs: Any) -> ItemPaged["_models.Distri :return: An iterator like instance of DistributionPolicy :rtype: ~azure.core.paging.ItemPaged[~azure.communication.jobrouter.models.DistributionPolicy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1439,6 +2386,7 @@ def upsert_classification_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. @@ -1458,11 +2406,195 @@ def upsert_classification_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ @overload @@ -1477,6 +2609,7 @@ def upsert_classification_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. @@ -1496,18 +2629,135 @@ def upsert_classification_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ @overload def upsert_classification_policy( self, classification_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1515,6 +2765,7 @@ def upsert_classification_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. @@ -1522,7 +2773,7 @@ def upsert_classification_policy( :param classification_policy_id: Id of a classification policy. Required. :type classification_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1534,48 +2785,348 @@ def upsert_classification_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ @distributed_trace def upsert_classification_policy( self, classification_policy_id: str, - resource: Union[_models.ClassificationPolicy, JSON, IO], + resource: Union[_models.ClassificationPolicy, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. - :param classification_policy_id: Id of a classification policy. Required. - :type classification_policy_id: str - :param resource: The resource instance. Is one of the following types: ClassificationPolicy, - JSON, IO Required. - :type resource: ~azure.communication.jobrouter.models.ClassificationPolicy or JSON or IO - :keyword if_unmodified_since: The request should only proceed if the entity was not modified - after this time. Default value is None. - :paramtype if_unmodified_since: ~datetime.datetime - :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is - None. - :paramtype etag: str - :keyword match_condition: The match condition to use upon the etag. Default value is None. - :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. - :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping - :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy - :raises ~azure.core.exceptions.HttpResponseError: + :param classification_policy_id: Id of a classification policy. Required. + :type classification_policy_id: str + :param resource: The resource instance. Is one of the following types: ClassificationPolicy, + JSON, IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.ClassificationPolicy or JSON or IO[bytes] + :keyword if_unmodified_since: The request should only proceed if the entity was not modified + after this time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping + :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ error_map = { 401: ClientAuthenticationError, @@ -1659,17 +3210,85 @@ def upsert_classification_policy( @distributed_trace def get_classification_policy(self, classification_policy_id: str, **kwargs: Any) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Retrieves an existing classification policy by Id. Retrieves an existing classification policy by Id. :param classification_policy_id: Id of a classification policy. Required. :type classification_policy_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ error_map = { 401: ClientAuthenticationError, @@ -1722,8 +3341,10 @@ def get_classification_policy(self, classification_policy_id: str, **kwargs: Any return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_classification_policies(self, **kwargs: Any) -> ItemPaged["_models.ClassificationPolicy"]: + # pylint: disable=line-too-long """Retrieves existing classification policies. Retrieves existing classification policies. @@ -1732,6 +3353,75 @@ def list_classification_policies(self, **kwargs: Any) -> ItemPaged["_models.Clas :rtype: ~azure.core.paging.ItemPaged[~azure.communication.jobrouter.models.ClassificationPolicy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1896,11 +3586,44 @@ def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ @overload @@ -1934,18 +3657,35 @@ def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ @overload def upsert_exception_policy( self, exception_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1960,7 +3700,7 @@ def upsert_exception_policy( :param exception_policy_id: Id of an exception policy. Required. :type exception_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1972,18 +3712,35 @@ def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ @distributed_trace def upsert_exception_policy( self, exception_policy_id: str, - resource: Union[_models.ExceptionPolicy, JSON, IO], + resource: Union[_models.ExceptionPolicy, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, @@ -1997,8 +3754,8 @@ def upsert_exception_policy( :param exception_policy_id: Id of an exception policy. Required. :type exception_policy_id: str :param resource: The resource instance. Is one of the following types: ExceptionPolicy, JSON, - IO Required. - :type resource: ~azure.communication.jobrouter.models.ExceptionPolicy or JSON or IO + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.ExceptionPolicy or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -2007,13 +3764,44 @@ def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ error_map = { 401: ClientAuthenticationError, @@ -2103,11 +3891,28 @@ def get_exception_policy(self, exception_policy_id: str, **kwargs: Any) -> _mode :param exception_policy_id: Id of an exception policy. Required. :type exception_policy_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ error_map = { 401: ClientAuthenticationError, @@ -2160,6 +3965,7 @@ def get_exception_policy(self, exception_policy_id: str, **kwargs: Any) -> _mode return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_exception_policies(self, **kwargs: Any) -> ItemPaged["_models.ExceptionPolicy"]: """Retrieves existing exception policies. @@ -2169,6 +3975,25 @@ def list_exception_policies(self, **kwargs: Any) -> ItemPaged["_models.Exception :return: An iterator like instance of ExceptionPolicy :rtype: ~azure.core.paging.ItemPaged[~azure.communication.jobrouter.models.ExceptionPolicy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -2314,6 +4139,7 @@ def upsert_queue( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. @@ -2333,11 +4159,44 @@ def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ @overload @@ -2352,6 +4211,7 @@ def upsert_queue( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. @@ -2371,18 +4231,35 @@ def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ @overload def upsert_queue( self, queue_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -2390,6 +4267,7 @@ def upsert_queue( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. @@ -2397,7 +4275,7 @@ def upsert_queue( :param queue_id: Id of a queue. Required. :type queue_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2409,33 +4287,51 @@ def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ @distributed_trace def upsert_queue( self, queue_id: str, - resource: Union[_models.RouterQueue, JSON, IO], + resource: Union[_models.RouterQueue, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. :param queue_id: Id of a queue. Required. :type queue_id: str - :param resource: The resource instance. Is one of the following types: RouterQueue, JSON, IO - Required. - :type resource: ~azure.communication.jobrouter.models.RouterQueue or JSON or IO + :param resource: The resource instance. Is one of the following types: RouterQueue, JSON, + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.RouterQueue or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -2444,13 +4340,44 @@ def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ error_map = { 401: ClientAuthenticationError, @@ -2534,17 +4461,35 @@ def upsert_queue( @distributed_trace def get_queue(self, queue_id: str, **kwargs: Any) -> _models.RouterQueue: + # pylint: disable=line-too-long """Retrieves an existing queue by Id. Retrieves an existing queue by Id. :param queue_id: Id of a queue. Required. :type queue_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ error_map = { 401: ClientAuthenticationError, @@ -2597,8 +4542,10 @@ def get_queue(self, queue_id: str, **kwargs: Any) -> _models.RouterQueue: return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_queues(self, **kwargs: Any) -> ItemPaged["_models.RouterQueue"]: + # pylint: disable=line-too-long """Retrieves existing queues. Retrieves existing queues. @@ -2606,6 +4553,25 @@ def list_queues(self, **kwargs: Any) -> ItemPaged["_models.RouterQueue"]: :return: An iterator like instance of RouterQueue :rtype: ~azure.core.paging.ItemPaged[~azure.communication.jobrouter.models.RouterQueue] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -2751,6 +4717,7 @@ def upsert_job( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. @@ -2770,11 +4737,259 @@ def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ @overload @@ -2789,6 +5004,7 @@ def upsert_job( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. @@ -2808,18 +5024,151 @@ def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ @overload def upsert_job( self, job_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -2827,6 +5176,7 @@ def upsert_job( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. @@ -2834,7 +5184,7 @@ def upsert_job( :param job_id: Id of a job. Required. :type job_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2846,33 +5196,167 @@ def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ @distributed_trace def upsert_job( self, job_id: str, - resource: Union[_models.RouterJob, JSON, IO], + resource: Union[_models.RouterJob, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. :param job_id: Id of a job. Required. :type job_id: str - :param resource: The resource instance. Is one of the following types: RouterJob, JSON, IO - Required. - :type resource: ~azure.communication.jobrouter.models.RouterJob or JSON or IO + :param resource: The resource instance. Is one of the following types: RouterJob, JSON, + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.RouterJob or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -2881,13 +5365,259 @@ def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -2971,17 +5701,133 @@ def upsert_job( @distributed_trace def get_job(self, job_id: str, **kwargs: Any) -> _models.RouterJob: + # pylint: disable=line-too-long """Retrieves an existing job by Id. Retrieves an existing job by Id. :param job_id: Id of a job. Required. :type job_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -3105,7 +5951,7 @@ def _reclassify_job( # pylint: disable=protected-access @overload def _reclassify_job( # pylint: disable=protected-access - self, job_id: str, options: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, job_id: str, options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models._models.ReclassifyJobResult: ... @@ -3113,7 +5959,7 @@ def _reclassify_job( # pylint: disable=protected-access def _reclassify_job( # pylint: disable=protected-access self, job_id: str, - options: Optional[Union[_models._models.ReclassifyJobOptions, JSON, IO]] = None, + options: Optional[Union[_models._models.ReclassifyJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.ReclassifyJobResult: """Reclassify a job. @@ -3123,16 +5969,17 @@ def _reclassify_job( # pylint: disable=protected-access :param job_id: Id of a job. Required. :type job_id: str :param options: Request object for reclassifying a job. Is one of the following types: - ReclassifyJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.ReclassifyJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + ReclassifyJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.ReclassifyJobOptions or JSON or IO[bytes] :return: ReclassifyJobResult. The ReclassifyJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ReclassifyJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = {} """ error_map = { 401: ClientAuthenticationError, @@ -3215,14 +6062,15 @@ def _cancel_job( # pylint: disable=protected-access @overload def _cancel_job( # pylint: disable=protected-access - self, job_id: str, options: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, job_id: str, options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models._models.CancelJobResult: ... @distributed_trace def _cancel_job( # pylint: disable=protected-access - self, job_id: str, options: Optional[Union[_models.CancelJobOptions, JSON, IO]] = None, **kwargs: Any + self, job_id: str, options: Optional[Union[_models.CancelJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.CancelJobResult: + # pylint: disable=line-too-long """Submits request to cancel an existing job by Id while supplying free-form cancellation reason. Submits request to cancel an existing job by Id while supplying free-form cancellation reason. @@ -3230,16 +6078,23 @@ def _cancel_job( # pylint: disable=protected-access :param job_id: Id of a job. Required. :type job_id: str :param options: Request model for cancelling job. Is one of the following types: - CancelJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.CancelJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + CancelJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.CancelJobOptions or JSON or IO[bytes] :return: CancelJobResult. The CancelJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.CancelJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "dispositionCode": "str", # Optional. Indicates the outcome of a job, + populate this field with your own custom values. If not provided, default value + of "Cancelled" is set. + "note": "str" # Optional. A note that will be appended to a job's Notes + collection with the current timestamp. + } """ error_map = { 401: ClientAuthenticationError, @@ -3332,7 +6187,7 @@ def _complete_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -3344,7 +6199,7 @@ def _complete_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[Union[_models.CompleteJobOptions, JSON, IO]] = None, + options: Optional[Union[_models.CompleteJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.CompleteJobResult: """Completes an assigned job. @@ -3356,16 +6211,20 @@ def _complete_job( # pylint: disable=protected-access :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request model for completing job. Is one of the following types: - CompleteJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.CompleteJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + CompleteJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.CompleteJobOptions or JSON or IO[bytes] :return: CompleteJobResult. The CompleteJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.CompleteJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "note": "str" # Optional. A note that will be appended to a job's Notes + collection with the current timestamp. + } """ error_map = { 401: ClientAuthenticationError, @@ -3459,7 +6318,7 @@ def _close_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -3471,9 +6330,10 @@ def _close_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[Union[_models.CloseJobOptions, JSON, IO]] = None, + options: Optional[Union[_models.CloseJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.CloseJobResult: + # pylint: disable=line-too-long """Closes a completed job. Closes a completed job. @@ -3483,16 +6343,26 @@ def _close_job( # pylint: disable=protected-access :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request model for closing job. Is one of the following types: CloseJobOptions, - JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.CloseJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.CloseJobOptions or JSON or IO[bytes] :return: CloseJobResult. The CloseJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.CloseJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "closeAt": "2020-02-20 00:00:00", # Optional. If not provided, worker + capacity is released immediately along with a JobClosedEvent notification. If + provided, worker capacity is released along with a JobClosedEvent notification at + a future time in UTC. + "dispositionCode": "str", # Optional. Indicates the outcome of a job, + populate this field with your own custom values. + "note": "str" # Optional. A note that will be appended to a job's Notes + collection with the current timestamp. + } """ error_map = { 401: ClientAuthenticationError, @@ -3557,6 +6427,7 @@ def _close_job( # pylint: disable=protected-access return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_jobs( self, @@ -3569,6 +6440,7 @@ def list_jobs( scheduled_after: Optional[datetime.datetime] = None, **kwargs: Any ) -> ItemPaged["_models.RouterJob"]: + # pylint: disable=line-too-long """Retrieves list of jobs based on filter parameters. Retrieves list of jobs based on filter parameters. @@ -3594,6 +6466,123 @@ def list_jobs( :return: An iterator like instance of RouterJob :rtype: ~azure.core.paging.ItemPaged[~azure.communication.jobrouter.models.RouterJob] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -3687,12 +6676,25 @@ def get_queue_position(self, job_id: str, **kwargs: Any) -> _models.RouterJobPos :param job_id: Id of the job. Required. :type job_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJobPositionDetails. The RouterJobPositionDetails is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJobPositionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "estimatedWaitTimeMinutes": 0.0, # Estimated wait time of the job rounded up + to the nearest minute. Required. + "jobId": "str", # Id of the job these details are about. Required. + "position": 0, # Position of the job in question within that queue. + Required. + "queueId": "str", # Id of the queue this job is enqueued in. Required. + "queueLength": 0 # Length of the queue: total number of enqueued jobs. + Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -3751,6 +6753,7 @@ def unassign_job( content_type: str = "application/json", **kwargs: Any ) -> _models.UnassignJobResult: + # pylint: disable=line-too-long """Unassign a job. Unassign a job. @@ -3764,11 +6767,25 @@ def unassign_job( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "suspendMatching": bool # Optional. If SuspendMatching is true, then a job + is not queued for re-matching with a worker. + } + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ @overload @@ -3794,11 +6811,19 @@ def unassign_job( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ @overload @@ -3806,7 +6831,7 @@ def unassign_job( self, job_id: str, assignment_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -3820,15 +6845,23 @@ def unassign_job( :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request body for unassign route. Default value is None. - :type options: IO + :type options: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ @distributed_trace @@ -3836,9 +6869,10 @@ def unassign_job( self, job_id: str, assignment_id: str, - options: Optional[Union[_models.UnassignJobOptions, JSON, IO]] = None, + options: Optional[Union[_models.UnassignJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models.UnassignJobResult: + # pylint: disable=line-too-long """Unassign a job. Unassign a job. @@ -3848,16 +6882,27 @@ def unassign_job( :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request body for unassign route. Is one of the following types: - UnassignJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.UnassignJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + UnassignJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.UnassignJobOptions or JSON or IO[bytes] :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "suspendMatching": bool # Optional. If SuspendMatching is true, then a job + is not queued for re-matching with a worker. + } + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -3932,11 +6977,21 @@ def accept_job_offer(self, worker_id: str, offer_id: str, **kwargs: Any) -> _mod :type worker_id: str :param offer_id: Id of an offer. Required. :type offer_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: AcceptJobOfferResult. The AcceptJobOfferResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.AcceptJobOfferResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "assignmentId": "str", # Id of job assignment that assigns a worker that has + accepted an offer to a job. Required. + "jobId": "str", # Id of the job assigned. Required. + "workerId": "str" # Id of the worker that has been assigned this job. + Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -4015,7 +7070,7 @@ def _decline_job_offer( # pylint: disable=protected-access self, worker_id: str, offer_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -4027,9 +7082,10 @@ def _decline_job_offer( # pylint: disable=protected-access self, worker_id: str, offer_id: str, - options: Optional[Union[_models.DeclineJobOfferOptions, JSON, IO]] = None, + options: Optional[Union[_models.DeclineJobOfferOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.DeclineJobOfferResult: + # pylint: disable=line-too-long """Declines an offer to work on a job. Declines an offer to work on a job. @@ -4039,16 +7095,25 @@ def _decline_job_offer( # pylint: disable=protected-access :param offer_id: Id of an offer. Required. :type offer_id: str :param options: Request model for declining offer. Is one of the following types: - DeclineJobOfferOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.DeclineJobOfferOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + DeclineJobOfferOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.DeclineJobOfferOptions or JSON or + IO[bytes] :return: DeclineJobOfferResult. The DeclineJobOfferResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DeclineJobOfferResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "retryOfferAt": "2020-02-20 00:00:00" # Optional. If the RetryOfferAt is not + provided, then this job will not be offered again to the worker who declined this + job unless the worker is de-registered and re-registered. If a RetryOfferAt time + is provided, then the job will be re-matched to eligible workers at the retry + time in UTC. The worker that declined the job will also be eligible for the job + at that time. + } """ error_map = { 401: ClientAuthenticationError, @@ -4117,17 +7182,31 @@ def _decline_job_offer( # pylint: disable=protected-access @distributed_trace def get_queue_statistics(self, queue_id: str, **kwargs: Any) -> _models.RouterQueueStatistics: + # pylint: disable=line-too-long """Retrieves a queue's statistics. Retrieves a queue's statistics. :param queue_id: Id of the queue to retrieve statistics. Required. :type queue_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueueStatistics. The RouterQueueStatistics is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueueStatistics :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "length": 0, # Length of the queue: total number of enqueued jobs. Required. + "queueId": "str", # Id of the queue these details are about. Required. + "estimatedWaitTimeMinutes": { + "str": 0.0 # Optional. The estimated wait time of this queue rounded + up to the nearest minute, grouped by job priority. + }, + "longestJobWaitTimeMinutes": 0.0 # Optional. The wait time of the job that + has been enqueued in this queue for the longest. + } """ error_map = { 401: ClientAuthenticationError, @@ -4188,6 +7267,7 @@ def upsert_worker( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. @@ -4207,11 +7287,136 @@ def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ @overload @@ -4226,6 +7431,7 @@ def upsert_worker( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. @@ -4245,18 +7451,81 @@ def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ @overload def upsert_worker( self, worker_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -4264,6 +7533,7 @@ def upsert_worker( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. @@ -4271,7 +7541,7 @@ def upsert_worker( :param worker_id: Id of a worker. Required. :type worker_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -4283,33 +7553,97 @@ def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ @distributed_trace def upsert_worker( self, worker_id: str, - resource: Union[_models.RouterWorker, JSON, IO], + resource: Union[_models.RouterWorker, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. :param worker_id: Id of a worker. Required. :type worker_id: str - :param resource: The resource instance. Is one of the following types: RouterWorker, JSON, IO - Required. - :type resource: ~azure.communication.jobrouter.models.RouterWorker or JSON or IO + :param resource: The resource instance. Is one of the following types: RouterWorker, JSON, + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.RouterWorker or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -4318,13 +7652,136 @@ def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -4408,17 +7865,81 @@ def upsert_worker( @distributed_trace def get_worker(self, worker_id: str, **kwargs: Any) -> _models.RouterWorker: + # pylint: disable=line-too-long """Retrieves an existing worker by Id. Retrieves an existing worker by Id. :param worker_id: Id of a worker. Required. :type worker_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -4523,6 +8044,7 @@ def delete_worker(self, worker_id: str, **kwargs: Any) -> None: # pylint: disab if cls: return cls(pipeline_response, None, {}) # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_workers( self, @@ -4533,6 +8055,7 @@ def list_workers( has_capacity: Optional[bool] = None, **kwargs: Any ) -> ItemPaged["_models.RouterWorker"]: + # pylint: disable=line-too-long """Retrieves existing workers. Retrieves existing workers. @@ -4554,6 +8077,71 @@ def list_workers( :return: An iterator like instance of RouterWorker :rtype: ~azure.core.paging.ItemPaged[~azure.communication.jobrouter.models.RouterWorker] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_patch.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_patch.py index d43d09200632..8309db3a2f96 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_patch.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_patch.py @@ -169,7 +169,7 @@ def upsert_exception_policy( def upsert_exception_policy( self, exception_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -184,7 +184,7 @@ def upsert_exception_policy( :param exception_policy_id: The Id of the exception policy. Required. :type exception_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -204,7 +204,7 @@ def upsert_exception_policy( """ def upsert_exception_policy( - self, exception_policy_id: str, *args: Union[_models.ExceptionPolicy, JSON, IO], **kwargs: Any + self, exception_policy_id: str, *args: Union[_models.ExceptionPolicy, JSON, IO[bytes]], **kwargs: Any ) -> _models.ExceptionPolicy: """Update an exception policy. @@ -242,7 +242,7 @@ def upsert_exception_policy( if not exception_policy_id: raise ValueError("exception_policy_id cannot be None.") - exception_policy: Union[_models.ExceptionPolicy, JSON, IO] = _models.ExceptionPolicy() + exception_policy: Union[_models.ExceptionPolicy, JSON, IO[bytes]] = _models.ExceptionPolicy() if len(args) == 1: exception_policy = args[0] @@ -431,7 +431,7 @@ def upsert_distribution_policy( def upsert_distribution_policy( self, distribution_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -446,7 +446,7 @@ def upsert_distribution_policy( :param distribution_policy_id: The unique identifier of the policy. Required. :type distribution_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -466,7 +466,7 @@ def upsert_distribution_policy( """ def upsert_distribution_policy( - self, distribution_policy_id: str, *args: Union[_models.DistributionPolicy, JSON, IO], **kwargs: Any + self, distribution_policy_id: str, *args: Union[_models.DistributionPolicy, JSON, IO[bytes]], **kwargs: Any ) -> _models.DistributionPolicy: """Update a distribution policy. @@ -511,7 +511,7 @@ def upsert_distribution_policy( if not distribution_policy_id: raise ValueError("distribution_policy_id cannot be None.") - distribution_policy: Union[_models.DistributionPolicy, JSON, IO] = _models.DistributionPolicy() + distribution_policy: Union[_models.DistributionPolicy, JSON, IO[bytes]] = _models.DistributionPolicy() if len(args) == 1: distribution_policy = args[0] @@ -710,7 +710,7 @@ def upsert_queue( def upsert_queue( self, queue_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -725,7 +725,7 @@ def upsert_queue( :param queue_id: The Id of this queue. Required. :type queue_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -745,7 +745,7 @@ def upsert_queue( """ def upsert_queue( - self, queue_id: str, *args: Union[_models.RouterQueue, JSON, IO], **kwargs: Any + self, queue_id: str, *args: Union[_models.RouterQueue, JSON, IO[bytes]], **kwargs: Any ) -> _models.RouterQueue: """Update a job queue @@ -792,7 +792,7 @@ def upsert_queue( if not queue_id: raise ValueError("queue_id cannot be None.") - queue: Union[_models.RouterQueue, JSON, IO] = _models.RouterQueue() + queue: Union[_models.RouterQueue, JSON, IO[bytes]] = _models.RouterQueue() if len(args) == 1: queue = args[0] @@ -1027,7 +1027,7 @@ def upsert_classification_policy( def upsert_classification_policy( self, classification_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1042,7 +1042,7 @@ def upsert_classification_policy( :param classification_policy_id: Unique identifier of this policy. Required. :type classification_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1062,7 +1062,7 @@ def upsert_classification_policy( """ def upsert_classification_policy( - self, classification_policy_id: str, *args: Union[_models.ClassificationPolicy, JSON, IO], **kwargs: Any + self, classification_policy_id: str, *args: Union[_models.ClassificationPolicy, JSON, IO[bytes]], **kwargs: Any ) -> _models.ClassificationPolicy: """Update a classification policy @@ -1120,7 +1120,7 @@ def upsert_classification_policy( if not classification_policy_id: raise ValueError("classification_policy_id cannot be None.") - classification_policy: Union[_models.ClassificationPolicy, JSON, IO] = _models.ClassificationPolicy() + classification_policy: Union[_models.ClassificationPolicy, JSON, IO[bytes]] = _models.ClassificationPolicy() if len(args) == 1: classification_policy = args[0] @@ -1199,6 +1199,7 @@ def upsert_worker( # pylint: disable=arguments-differ,unused-argument tags: Optional[Dict[str, Union[int, float, str, bool]]], channels: Optional[List[_models.RouterChannel]], available_for_offers: Optional[bool], + max_concurrent_offers: Optional[int], if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1230,6 +1231,10 @@ def upsert_worker( # pylint: disable=arguments-differ,unused-argument :keyword available_for_offers: A flag indicating this worker is open to receive offers or not. :paramtype available_for_offers: Optional[bool] + :keyword max_concurrent_offers: If this is set, the worker will only receive up to this many new + offers at a time. + :paramtype max_concurrent_offers: Optional[int] + :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1351,7 +1356,7 @@ def upsert_worker( def upsert_worker( self, worker_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1366,7 +1371,7 @@ def upsert_worker( :param worker_id: Id of the worker. Required. :type worker_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1386,7 +1391,7 @@ def upsert_worker( """ def upsert_worker( - self, worker_id: str, *args: Union[_models.RouterWorker, JSON, IO], **kwargs: Any + self, worker_id: str, *args: Union[_models.RouterWorker, JSON, IO[bytes]], **kwargs: Any ) -> _models.RouterWorker: """Update a router worker. @@ -1414,6 +1419,10 @@ def upsert_worker( :keyword available_for_offers: A flag indicating this worker is open to receive offers or not. :paramtype available_for_offers: Optional[bool] + :keyword max_concurrent_offers: If this is set, the worker will only receive up to this many new + offers at a time. + :paramtype max_concurrent_offers: Optional[int] + :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1453,11 +1462,20 @@ def upsert_worker( :language: python :dedent: 8 :caption: Use a JobRouterClient to de-register a worker + + .. admonition:: Example: + + .. literalinclude:: ../samples/router_worker_crud_ops.py + :start-after: [START create_worker_w_limit_concurrent_offers] + :end-before: [END create_worker_w_limit_concurrent_offers] + :language: python + :dedent: 8 + :caption: Use a JobRouterClient to create a worker with concurrent offer limit """ if not worker_id: raise ValueError("worker_id cannot be None.") - router_worker: Union[_models.RouterWorker, JSON, IO] = _models.RouterWorker() + router_worker: Union[_models.RouterWorker, JSON, IO[bytes]] = _models.RouterWorker() if len(args) == 1: router_worker = args[0] @@ -1470,6 +1488,7 @@ def upsert_worker( tags=kwargs.pop("tags", router_worker.tags), channels=kwargs.pop("channels", router_worker.channels), available_for_offers=kwargs.pop("available_for_offers", router_worker.available_for_offers), + max_concurrent_offers=kwargs.pop("max_concurrent_offers", router_worker.max_concurrent_offers), ) if_unmodified_since = kwargs.pop("if_unmodified_since", None) @@ -1715,7 +1734,7 @@ def upsert_job( def upsert_job( self, job_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1730,7 +1749,7 @@ def upsert_job( :param job_id: The id of the job. Required. :type job_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1749,7 +1768,12 @@ def upsert_job( :raises ~azure.core.exceptions.HttpResponseError: """ - def upsert_job(self, job_id: str, *args: Union[_models.RouterJob, JSON, IO], **kwargs: Any) -> _models.RouterJob: + def upsert_job( + self, + job_id: str, + *args: Union[_models.RouterJob, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RouterJob: """Update a job. :param str job_id: Id of the job. @@ -1816,7 +1840,7 @@ def upsert_job(self, job_id: str, *args: Union[_models.RouterJob, JSON, IO], **k if not job_id: raise ValueError("job_id cannot be None.") - router_job: Union[_models.RouterJob, JSON, IO] = _models.RouterJob() + router_job: Union[_models.RouterJob, JSON, IO[bytes]] = _models.RouterJob() if len(args) == 1: router_job = args[0] diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_serialization.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_serialization.py index 8c265befc2aa..2f781d740827 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_serialization.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_serialization.py @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -545,7 +538,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -745,7 +738,7 @@ def query(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :keyword bool skip_quote: Whether to skip quote the serialized result. Defaults to False. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1370,7 +1363,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1860,7 +1853,7 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) raise DeserializationError(msg) from err @@ -1996,6 +1989,7 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_shared/models.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_shared/models.py index 7b646472045c..d5ad25d9cdb0 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_shared/models.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_shared/models.py @@ -11,11 +11,13 @@ class DeprecatedEnumMeta(CaseInsensitiveEnumMeta): - def __getattribute__(cls, item): if item.upper() == "MICROSOFT_BOT": - warnings.warn("MICROSOFT_BOT is deprecated and has been replaced by \ - MICROSOFT_TEAMS_APP identifier.", DeprecationWarning) + warnings.warn( + "MICROSOFT_BOT is deprecated and has been replaced by \ + MICROSOFT_TEAMS_APP identifier.", + DeprecationWarning, + ) item = "MICROSOFT_TEAMS_APP" return super().__getattribute__(item) @@ -47,14 +49,17 @@ class CommunicationCloudEnvironment(str, Enum, metaclass=CaseInsensitiveEnumMeta @runtime_checkable class CommunicationIdentifier(Protocol): """Communication Identifier.""" + @property def raw_id(self) -> str: """The raw ID of the identifier.""" ... + @property def kind(self) -> CommunicationIdentifierKind: """The type of identifier.""" ... + @property def properties(self) -> Mapping[str, Any]: """The properties of the identifier.""" @@ -83,12 +88,14 @@ def properties(self) -> Mapping[str, Any]: class CommunicationUserProperties(TypedDict): """Dictionary of properties for a CommunicationUserIdentifier.""" + id: str """ID of the Communication user as returned from Azure Communication Identity.""" class CommunicationUserIdentifier: """Represents a user in Azure Communication Service.""" + kind: Literal[CommunicationIdentifierKind.COMMUNICATION_USER] = CommunicationIdentifierKind.COMMUNICATION_USER """The type of identifier.""" properties: CommunicationUserProperties @@ -116,12 +123,14 @@ def __eq__(self, other): class PhoneNumberProperties(TypedDict): """Dictionary of properties for a PhoneNumberIdentifier.""" + value: str """The phone number in E.164 format.""" class PhoneNumberIdentifier: """Represents a phone number.""" + kind: Literal[CommunicationIdentifierKind.PHONE_NUMBER] = CommunicationIdentifierKind.PHONE_NUMBER """The type of identifier.""" properties: PhoneNumberProperties @@ -165,6 +174,7 @@ class UnknownIdentifier: It is not advisable to rely on the `kind` property with a value `unknown`, as it could become a new or existing distinct type in the future. """ + kind: Literal[CommunicationIdentifierKind.UNKNOWN] = CommunicationIdentifierKind.UNKNOWN """The type of identifier.""" properties: Mapping[str, Any] @@ -188,6 +198,7 @@ def __eq__(self, other): class MicrosoftTeamsUserProperties(TypedDict): """Dictionary of properties for a MicrosoftTeamsUserIdentifier.""" + user_id: str """The id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.""" is_anonymous: bool @@ -198,6 +209,7 @@ class MicrosoftTeamsUserProperties(TypedDict): class MicrosoftTeamsUserIdentifier: """Represents an identifier for a Microsoft Teams user.""" + kind: Literal[CommunicationIdentifierKind.MICROSOFT_TEAMS_USER] = CommunicationIdentifierKind.MICROSOFT_TEAMS_USER """The type of identifier.""" properties: MicrosoftTeamsUserProperties @@ -246,6 +258,7 @@ def _format_raw_id(self, properties: MicrosoftTeamsUserProperties) -> str: class MicrosoftTeamsAppProperties(TypedDict): """Dictionary of properties for a MicrosoftTeamsAppIdentifier.""" + app_id: str """The id of the Microsoft Teams application.""" cloud: Union[CommunicationCloudEnvironment, str] @@ -254,6 +267,7 @@ class MicrosoftTeamsAppProperties(TypedDict): class _botbackcompatdict(dict): """Backwards compatible properties.""" + def __getitem__(self, __key: Any) -> Any: try: return super().__getitem__(__key) @@ -267,6 +281,7 @@ def __getitem__(self, __key: Any) -> Any: class MicrosoftTeamsAppIdentifier: """Represents an identifier for a Microsoft Teams application.""" + kind: Literal[CommunicationIdentifierKind.MICROSOFT_TEAMS_APP] = CommunicationIdentifierKind.MICROSOFT_TEAMS_APP """The type of identifier.""" properties: MicrosoftTeamsAppProperties @@ -282,10 +297,13 @@ def __init__(self, app_id: str, **kwargs: Any) -> None: :keyword str raw_id: The raw ID of the identifier. If not specified, this value will be constructed from the other properties. """ - self.properties = cast(MicrosoftTeamsAppProperties, _botbackcompatdict( - app_id=app_id, - cloud=kwargs.get("cloud") or CommunicationCloudEnvironment.PUBLIC, - )) + self.properties = cast( + MicrosoftTeamsAppProperties, + _botbackcompatdict( + app_id=app_id, + cloud=kwargs.get("cloud") or CommunicationCloudEnvironment.PUBLIC, + ), + ) raw_id: Optional[str] = kwargs.get("raw_id") self.raw_id = raw_id if raw_id is not None else self._format_raw_id(self.properties) @@ -323,7 +341,7 @@ def __init__(self, bot_id, **kwargs): """ warnings.warn( "The MicrosoftBotIdentifier is deprecated and has been replaced by MicrosoftTeamsAppIdentifier.", - DeprecationWarning + DeprecationWarning, ) super().__init__(bot_id, **kwargs) @@ -339,9 +357,7 @@ def identifier_from_raw_id(raw_id: str) -> CommunicationIdentifier: # pylint: d :rtype: CommunicationIdentifier """ if raw_id.startswith(PHONE_NUMBER_PREFIX): - return PhoneNumberIdentifier( - value=raw_id[len(PHONE_NUMBER_PREFIX) :], raw_id=raw_id - ) + return PhoneNumberIdentifier(value=raw_id[len(PHONE_NUMBER_PREFIX) :], raw_id=raw_id) segments = raw_id.split(":", maxsplit=2) if len(segments) < 3: @@ -350,9 +366,7 @@ def identifier_from_raw_id(raw_id: str) -> CommunicationIdentifier: # pylint: d prefix = f"{segments[0]}:{segments[1]}:" suffix = segments[2] if prefix == TEAMS_USER_ANONYMOUS_PREFIX: - return MicrosoftTeamsUserIdentifier( - user_id=suffix, is_anonymous=True, raw_id=raw_id - ) + return MicrosoftTeamsUserIdentifier(user_id=suffix, is_anonymous=True, raw_id=raw_id) if prefix == TEAMS_USER_PUBLIC_CLOUD_PREFIX: return MicrosoftTeamsUserIdentifier( user_id=suffix, diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py index 0ec13ea52bbf..a1f432eddc4e 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.1.0b1" diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_client.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_client.py index 9d9a25d2b0ce..ddf6e6531806 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_client.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_client.py @@ -25,8 +25,9 @@ class JobRouterAdministrationClient( :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -102,8 +103,9 @@ class JobRouterClient(JobRouterClientOperationsMixin): # pylint: disable=client :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_configuration.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_configuration.py index 30c36dad559e..038bdbcfaf66 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_configuration.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_configuration.py @@ -21,13 +21,14 @@ class JobRouterAdministrationClientConfiguration: # pylint: disable=too-many-in :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-01-18-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -58,13 +59,14 @@ class JobRouterClientConfiguration: # pylint: disable=too-many-instance-attribu :param endpoint: Uri of your Communication resource. Required. :type endpoint: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-01-18-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-01-18-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_operations.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_operations.py index d0741ef97a49..eaf994cd5d91 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_operations.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -93,6 +93,7 @@ async def upsert_distribution_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -112,11 +113,246 @@ async def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ @overload @@ -131,6 +367,7 @@ async def upsert_distribution_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -150,18 +387,171 @@ async def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ @overload async def upsert_distribution_policy( self, distribution_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -169,6 +559,7 @@ async def upsert_distribution_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -176,7 +567,7 @@ async def upsert_distribution_policy( :param distribution_policy_id: Id of a distribution policy. Required. :type distribution_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -188,24 +579,178 @@ async def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ @distributed_trace_async async def upsert_distribution_policy( self, distribution_policy_id: str, - resource: Union[_models.DistributionPolicy, JSON, IO], + resource: Union[_models.DistributionPolicy, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Creates or updates a distribution policy. Creates or updates a distribution policy. @@ -213,8 +758,8 @@ async def upsert_distribution_policy( :param distribution_policy_id: Id of a distribution policy. Required. :type distribution_policy_id: str :param resource: The resource instance. Is one of the following types: DistributionPolicy, - JSON, IO Required. - :type resource: ~azure.communication.jobrouter.models.DistributionPolicy or JSON or IO + JSON, IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.DistributionPolicy or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -223,13 +768,246 @@ async def upsert_distribution_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ error_map = { 401: ClientAuthenticationError, @@ -313,17 +1091,100 @@ async def upsert_distribution_policy( @distributed_trace_async async def get_distribution_policy(self, distribution_policy_id: str, **kwargs: Any) -> _models.DistributionPolicy: + # pylint: disable=line-too-long """Retrieves an existing distribution policy by Id. Retrieves an existing distribution policy by Id. :param distribution_policy_id: Id of a distribution policy. Required. :type distribution_policy_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: DistributionPolicy. The DistributionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DistributionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ error_map = { 401: ClientAuthenticationError, @@ -376,8 +1237,10 @@ async def get_distribution_policy(self, distribution_policy_id: str, **kwargs: A return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_distribution_policies(self, **kwargs: Any) -> AsyncItemPaged["_models.DistributionPolicy"]: + # pylint: disable=line-too-long """Retrieves existing distribution policies. Retrieves existing distribution policies. @@ -386,6 +1249,90 @@ def list_distribution_policies(self, **kwargs: Any) -> AsyncItemPaged["_models.D :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.DistributionPolicy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "bestWorker": + distribution_mode = { + "kind": "bestWorker", + "bypassSelectors": bool, # Optional. If set to true, then router will match + workers to jobs even if they don't match label selectors. Warning: You may get + workers that are not qualified for a job they are matched with if you set this + variable to true. This flag is intended more for temporary usage. By default, set + to false. + "maxConcurrentOffers": 0, # Optional. Governs the maximum number of active + concurrent offers a job can have. + "minConcurrentOffers": 0, # Optional. Governs the minimum desired number of + active concurrent offers a job can have. + "scoringRule": router_rule, + "scoringRuleOptions": { + "batchSize": 0, # Optional. Set batch size when + 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. + "descendingOrder": bool, # Optional. If false, will sort scores by + ascending order. By default, set to true. + "isBatchScoringEnabled": bool, # Optional. If set to true, will + score workers in batches, and the parameter name of the worker labels will be + sent as ``workers``. By default, set to false and the parameter name for the + worker labels will be sent as ``worker``. Note: If enabled, use 'batchSize' + to set batch size. + "scoringParameters": [ + "str" # Optional. List of extra parameters from a job that + will be sent as part of the payload to scoring rule. If not set, a job's + labels (sent in the payload as ``job``"" ) and a job's worker selectors + (sent in the payload as ``selectors``"" ) are added to the payload of the + scoring rule by default. Note: Worker labels are always sent with scoring + payload. + ] + } + } + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a distribution policy. Required. + "mode": distribution_mode, + "name": "str", # Optional. Friendly name of this policy. + "offerExpiresAfterSeconds": 0.0 # Optional. Number of seconds after which + any offers created under this policy will be expired. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -531,6 +1478,7 @@ async def upsert_classification_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. @@ -550,11 +1498,195 @@ async def upsert_classification_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ @overload @@ -569,6 +1701,7 @@ async def upsert_classification_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. @@ -588,18 +1721,135 @@ async def upsert_classification_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ @overload async def upsert_classification_policy( self, classification_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -607,6 +1857,7 @@ async def upsert_classification_policy( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. @@ -614,7 +1865,7 @@ async def upsert_classification_policy( :param classification_policy_id: Id of a classification policy. Required. :type classification_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -626,48 +1877,348 @@ async def upsert_classification_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ @distributed_trace_async async def upsert_classification_policy( self, classification_policy_id: str, - resource: Union[_models.ClassificationPolicy, JSON, IO], + resource: Union[_models.ClassificationPolicy, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Creates or updates a classification policy. Creates or updates a classification policy. - :param classification_policy_id: Id of a classification policy. Required. - :type classification_policy_id: str - :param resource: The resource instance. Is one of the following types: ClassificationPolicy, - JSON, IO Required. - :type resource: ~azure.communication.jobrouter.models.ClassificationPolicy or JSON or IO - :keyword if_unmodified_since: The request should only proceed if the entity was not modified - after this time. Default value is None. - :paramtype if_unmodified_since: ~datetime.datetime - :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is - None. - :paramtype etag: str - :keyword match_condition: The match condition to use upon the etag. Default value is None. - :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. - :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping - :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy - :raises ~azure.core.exceptions.HttpResponseError: + :param classification_policy_id: Id of a classification policy. Required. + :type classification_policy_id: str + :param resource: The resource instance. Is one of the following types: ClassificationPolicy, + JSON, IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.ClassificationPolicy or JSON or IO[bytes] + :keyword if_unmodified_since: The request should only proceed if the entity was not modified + after this time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping + :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ error_map = { 401: ClientAuthenticationError, @@ -753,17 +2304,85 @@ async def upsert_classification_policy( async def get_classification_policy( self, classification_policy_id: str, **kwargs: Any ) -> _models.ClassificationPolicy: + # pylint: disable=line-too-long """Retrieves an existing classification policy by Id. Retrieves an existing classification policy by Id. :param classification_policy_id: Id of a classification policy. Required. :type classification_policy_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ClassificationPolicy. The ClassificationPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ClassificationPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ error_map = { 401: ClientAuthenticationError, @@ -816,8 +2435,10 @@ async def get_classification_policy( return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_classification_policies(self, **kwargs: Any) -> AsyncItemPaged["_models.ClassificationPolicy"]: + # pylint: disable=line-too-long """Retrieves existing classification policies. Retrieves existing classification policies. @@ -826,6 +2447,75 @@ def list_classification_policies(self, **kwargs: Any) -> AsyncItemPaged["_models :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.ClassificationPolicy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "directMap": + router_rule = { + "kind": "directMap" + } + + # JSON input template for discriminator value "expression": + router_rule = { + "expression": "str", # An expression to evaluate. Should contain return + statement with calculated values. Required. + "kind": "expression", + "language": "str" # Optional. The expression language to compile to and + execute. "powerFx" + } + + # JSON input template for discriminator value "function": + router_rule = { + "functionUri": "str", # URL for Azure Function. Required. + "kind": "function", + "credential": { + "appKey": "str", # Optional. Access key scoped to a Azure Function + app. This key grants access to all functions under the app. + "clientId": "str", # Optional. Client id, when AppKey is provided In + context of Azure function, this is usually the name of the key. + "functionKey": "str" # Optional. Access key scoped to a particular + function. + } + } + + # JSON input template for discriminator value "static": + router_rule = { + "kind": "static", + "value": {} # Optional. The static value this rule always returns. Values + must be primitive values - number, string, boolean. + } + + # JSON input template for discriminator value "webhook": + router_rule = { + "kind": "webhook", + "authorizationServerUri": "str", # Optional. Uri for Authorization Server. + "clientCredential": { + "clientId": "str", # Optional. ClientId for Contoso Authorization + server. + "clientSecret": "str" # Optional. Client secret for Contoso + Authorization server. + }, + "webhookUri": "str" # Optional. Uri for Contoso's Web Server. + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a classification policy. Required. + "fallbackQueueId": "str", # Optional. Id of a fallback queue to select if + queue selector attachments doesn't find a match. + "name": "str", # Optional. Friendly name of this policy. + "prioritizationRule": router_rule, + "queueSelectorAttachments": [ + queue_selector_attachment + ], + "workerSelectorAttachments": [ + worker_selector_attachment + ] + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -990,11 +2680,44 @@ async def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ @overload @@ -1028,18 +2751,35 @@ async def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ @overload async def upsert_exception_policy( self, exception_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1054,7 +2794,7 @@ async def upsert_exception_policy( :param exception_policy_id: Id of an exception policy. Required. :type exception_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1066,18 +2806,35 @@ async def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ @distributed_trace_async async def upsert_exception_policy( self, exception_policy_id: str, - resource: Union[_models.ExceptionPolicy, JSON, IO], + resource: Union[_models.ExceptionPolicy, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, @@ -1091,8 +2848,8 @@ async def upsert_exception_policy( :param exception_policy_id: Id of an exception policy. Required. :type exception_policy_id: str :param resource: The resource instance. Is one of the following types: ExceptionPolicy, JSON, - IO Required. - :type resource: ~azure.communication.jobrouter.models.ExceptionPolicy or JSON or IO + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.ExceptionPolicy or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1101,13 +2858,44 @@ async def upsert_exception_policy( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ error_map = { 401: ClientAuthenticationError, @@ -1197,11 +2985,28 @@ async def get_exception_policy(self, exception_policy_id: str, **kwargs: Any) -> :param exception_policy_id: Id of an exception policy. Required. :type exception_policy_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: ExceptionPolicy. The ExceptionPolicy is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ExceptionPolicy :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ error_map = { 401: ClientAuthenticationError, @@ -1254,6 +3059,7 @@ async def get_exception_policy(self, exception_policy_id: str, **kwargs: Any) -> return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_exception_policies(self, **kwargs: Any) -> AsyncItemPaged["_models.ExceptionPolicy"]: """Retrieves existing exception policies. @@ -1264,6 +3070,25 @@ def list_exception_policies(self, **kwargs: Any) -> AsyncItemPaged["_models.Exce :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.ExceptionPolicy] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of an exception policy. Required. + "exceptionRules": [ + { + "actions": [ + exception_action + ], + "id": "str", # Id of an exception rule. Required. + "trigger": exception_trigger + } + ], + "name": "str" # Optional. Friendly name of this policy. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1409,6 +3234,7 @@ async def upsert_queue( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. @@ -1428,11 +3254,44 @@ async def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ @overload @@ -1447,6 +3306,7 @@ async def upsert_queue( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. @@ -1466,18 +3326,35 @@ async def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ @overload async def upsert_queue( self, queue_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1485,6 +3362,7 @@ async def upsert_queue( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. @@ -1492,7 +3370,7 @@ async def upsert_queue( :param queue_id: Id of a queue. Required. :type queue_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1504,33 +3382,51 @@ async def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ @distributed_trace_async async def upsert_queue( self, queue_id: str, - resource: Union[_models.RouterQueue, JSON, IO], + resource: Union[_models.RouterQueue, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterQueue: + # pylint: disable=line-too-long """Creates or updates a queue. Creates or updates a queue. :param queue_id: Id of a queue. Required. :type queue_id: str - :param resource: The resource instance. Is one of the following types: RouterQueue, JSON, IO - Required. - :type resource: ~azure.communication.jobrouter.models.RouterQueue or JSON or IO + :param resource: The resource instance. Is one of the following types: RouterQueue, JSON, + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.RouterQueue or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1539,13 +3435,44 @@ async def upsert_queue( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ error_map = { 401: ClientAuthenticationError, @@ -1629,17 +3556,35 @@ async def upsert_queue( @distributed_trace_async async def get_queue(self, queue_id: str, **kwargs: Any) -> _models.RouterQueue: + # pylint: disable=line-too-long """Retrieves an existing queue by Id. Retrieves an existing queue by Id. :param queue_id: Id of a queue. Required. :type queue_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueue. The RouterQueue is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueue :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ error_map = { 401: ClientAuthenticationError, @@ -1692,8 +3637,10 @@ async def get_queue(self, queue_id: str, **kwargs: Any) -> _models.RouterQueue: return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_queues(self, **kwargs: Any) -> AsyncItemPaged["_models.RouterQueue"]: + # pylint: disable=line-too-long """Retrieves existing queues. Retrieves existing queues. @@ -1702,6 +3649,25 @@ def list_queues(self, **kwargs: Any) -> AsyncItemPaged["_models.RouterQueue"]: :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.RouterQueue] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a queue. Required. + "distributionPolicyId": "str", # Optional. Id of a distribution policy that + will determine how a job is distributed to workers. + "exceptionPolicyId": "str", # Optional. Id of an exception policy that + determines various job escalation rules. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "name": "str" # Optional. Friendly name of this queue. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1849,6 +3815,7 @@ async def upsert_job( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. @@ -1868,11 +3835,259 @@ async def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ @overload @@ -1887,6 +4102,7 @@ async def upsert_job( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. @@ -1906,18 +4122,151 @@ async def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ @overload async def upsert_job( self, job_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1925,6 +4274,7 @@ async def upsert_job( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. @@ -1932,7 +4282,7 @@ async def upsert_job( :param job_id: Id of a job. Required. :type job_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1944,33 +4294,167 @@ async def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ @distributed_trace_async async def upsert_job( self, job_id: str, - resource: Union[_models.RouterJob, JSON, IO], + resource: Union[_models.RouterJob, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterJob: + # pylint: disable=line-too-long """Creates or updates a router job. Creates or updates a router job. :param job_id: Id of a job. Required. :type job_id: str - :param resource: The resource instance. Is one of the following types: RouterJob, JSON, IO - Required. - :type resource: ~azure.communication.jobrouter.models.RouterJob or JSON or IO + :param resource: The resource instance. Is one of the following types: RouterJob, JSON, + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.RouterJob or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1979,13 +4463,259 @@ async def upsert_job( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -2069,17 +4799,133 @@ async def upsert_job( @distributed_trace_async async def get_job(self, job_id: str, **kwargs: Any) -> _models.RouterJob: + # pylint: disable=line-too-long """Retrieves an existing job by Id. Retrieves an existing job by Id. :param job_id: Id of a job. Required. :type job_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJob. The RouterJob is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJob :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -2203,7 +5049,7 @@ async def _reclassify_job( # pylint: disable=protected-access @overload async def _reclassify_job( # pylint: disable=protected-access - self, job_id: str, options: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, job_id: str, options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models._models.ReclassifyJobResult: ... @@ -2211,7 +5057,7 @@ async def _reclassify_job( # pylint: disable=protected-access async def _reclassify_job( # pylint: disable=protected-access self, job_id: str, - options: Optional[Union[_models._models.ReclassifyJobOptions, JSON, IO]] = None, + options: Optional[Union[_models._models.ReclassifyJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.ReclassifyJobResult: """Reclassify a job. @@ -2221,16 +5067,17 @@ async def _reclassify_job( # pylint: disable=protected-access :param job_id: Id of a job. Required. :type job_id: str :param options: Request object for reclassifying a job. Is one of the following types: - ReclassifyJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.ReclassifyJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + ReclassifyJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.ReclassifyJobOptions or JSON or IO[bytes] :return: ReclassifyJobResult. The ReclassifyJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.ReclassifyJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = {} """ error_map = { 401: ClientAuthenticationError, @@ -2313,14 +5160,15 @@ async def _cancel_job( # pylint: disable=protected-access @overload async def _cancel_job( # pylint: disable=protected-access - self, job_id: str, options: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, job_id: str, options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models._models.CancelJobResult: ... @distributed_trace_async async def _cancel_job( # pylint: disable=protected-access - self, job_id: str, options: Optional[Union[_models.CancelJobOptions, JSON, IO]] = None, **kwargs: Any + self, job_id: str, options: Optional[Union[_models.CancelJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.CancelJobResult: + # pylint: disable=line-too-long """Submits request to cancel an existing job by Id while supplying free-form cancellation reason. Submits request to cancel an existing job by Id while supplying free-form cancellation reason. @@ -2328,16 +5176,23 @@ async def _cancel_job( # pylint: disable=protected-access :param job_id: Id of a job. Required. :type job_id: str :param options: Request model for cancelling job. Is one of the following types: - CancelJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.CancelJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + CancelJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.CancelJobOptions or JSON or IO[bytes] :return: CancelJobResult. The CancelJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.CancelJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "dispositionCode": "str", # Optional. Indicates the outcome of a job, + populate this field with your own custom values. If not provided, default value + of "Cancelled" is set. + "note": "str" # Optional. A note that will be appended to a job's Notes + collection with the current timestamp. + } """ error_map = { 401: ClientAuthenticationError, @@ -2430,7 +5285,7 @@ async def _complete_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2442,7 +5297,7 @@ async def _complete_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[Union[_models.CompleteJobOptions, JSON, IO]] = None, + options: Optional[Union[_models.CompleteJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.CompleteJobResult: """Completes an assigned job. @@ -2454,16 +5309,20 @@ async def _complete_job( # pylint: disable=protected-access :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request model for completing job. Is one of the following types: - CompleteJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.CompleteJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + CompleteJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.CompleteJobOptions or JSON or IO[bytes] :return: CompleteJobResult. The CompleteJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.CompleteJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "note": "str" # Optional. A note that will be appended to a job's Notes + collection with the current timestamp. + } """ error_map = { 401: ClientAuthenticationError, @@ -2557,7 +5416,7 @@ async def _close_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2569,9 +5428,10 @@ async def _close_job( # pylint: disable=protected-access self, job_id: str, assignment_id: str, - options: Optional[Union[_models.CloseJobOptions, JSON, IO]] = None, + options: Optional[Union[_models.CloseJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.CloseJobResult: + # pylint: disable=line-too-long """Closes a completed job. Closes a completed job. @@ -2581,16 +5441,26 @@ async def _close_job( # pylint: disable=protected-access :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request model for closing job. Is one of the following types: CloseJobOptions, - JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.CloseJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.CloseJobOptions or JSON or IO[bytes] :return: CloseJobResult. The CloseJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.CloseJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "closeAt": "2020-02-20 00:00:00", # Optional. If not provided, worker + capacity is released immediately along with a JobClosedEvent notification. If + provided, worker capacity is released along with a JobClosedEvent notification at + a future time in UTC. + "dispositionCode": "str", # Optional. Indicates the outcome of a job, + populate this field with your own custom values. + "note": "str" # Optional. A note that will be appended to a job's Notes + collection with the current timestamp. + } """ error_map = { 401: ClientAuthenticationError, @@ -2655,6 +5525,7 @@ async def _close_job( # pylint: disable=protected-access return deserialized # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_jobs( self, @@ -2667,6 +5538,7 @@ def list_jobs( scheduled_after: Optional[datetime.datetime] = None, **kwargs: Any ) -> AsyncItemPaged["_models.RouterJob"]: + # pylint: disable=line-too-long """Retrieves list of jobs based on filter parameters. Retrieves list of jobs based on filter parameters. @@ -2693,6 +5565,123 @@ def list_jobs( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.RouterJob] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "queueAndMatch": + job_matching_mode = { + "kind": "queueAndMatch" + } + + # JSON input template for discriminator value "scheduleAndSuspend": + job_matching_mode = { + "kind": "scheduleAndSuspend", + "scheduleAt": "2020-02-20 00:00:00" # Requested schedule time. Required. + } + + # JSON input template for discriminator value "suspend": + job_matching_mode = { + "kind": "suspend" + } + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a job. Required. + "assignments": { + "str": { + "assignedAt": "2020-02-20 00:00:00", # Timestamp when the + job was assigned to a worker in UTC. Required. + "assignmentId": "str", # Id of a job assignment. Required. + "closedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as closed after being completed in UTC. + "completedAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the job was marked as completed after being assigned in UTC. + "workerId": "str" # Optional. Id of the Worker assigned to + the job. + } + }, + "attachedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "channelId": "str", # Optional. The channel identifier. eg. voice, chat, + etc. + "channelReference": "str", # Optional. Reference to an external parent + context, eg. call ID. + "classificationPolicyId": "str", # Optional. Id of a classification policy + used for classifying this job. + "dispositionCode": "str", # Optional. Reason code for cancelled or closed + jobs. + "enqueuedAt": "2020-02-20 00:00:00", # Optional. Timestamp a job was queued + in UTC. + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "matchingMode": job_matching_mode, + "notes": [ + { + "message": "str", # The message contained in the note. + Required. + "addedAt": "2020-02-20 00:00:00" # Optional. The time at + which the note was added in UTC. If not provided, will default to the + current time. + } + ], + "priority": 0, # Optional. Priority of this job. + "queueId": "str", # Optional. Id of a queue that this job is queued to. + "requestedWorkerSelectors": [ + { + "key": "str", # The label key to query against. Required. + "labelOperator": "str", # Describes how the value of the + label is compared to the value defined on the worker selector. Required. + Known values are: "equal", "notEqual", "lessThan", "lessThanOrEqual", + "greaterThan", and "greaterThanOrEqual". + "expedite": bool, # Optional. Pushes a job to the front of + the queue as long as this selector is active. + "expiresAfterSeconds": 0.0, # Optional. Describes how long + this label selector is valid in seconds. + "expiresAt": "2020-02-20 00:00:00", # Optional. The time at + which this worker selector expires in UTC. + "status": "str", # Optional. Status of the worker selector. + Known values are: "active" and "expired". + "value": {} # Optional. The value to compare against the + actual label value with the given operator. Values must be primitive + values - number, string, boolean. + } + ], + "scheduledAt": "2020-02-20 00:00:00", # Optional. If set, job will be + scheduled to be enqueued at a given time. + "status": "str", # Optional. The status of the job. Known values are: + "pendingClassification", "queued", "assigned", "completed", "closed", + "cancelled", "classificationFailed", "created", "pendingSchedule", "scheduled", + "scheduleFailed", and "waitingForActivation". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this job. Values must be primitive values - number, string, boolean. + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -2786,12 +5775,25 @@ async def get_queue_position(self, job_id: str, **kwargs: Any) -> _models.Router :param job_id: Id of the job. Required. :type job_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterJobPositionDetails. The RouterJobPositionDetails is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterJobPositionDetails :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "estimatedWaitTimeMinutes": 0.0, # Estimated wait time of the job rounded up + to the nearest minute. Required. + "jobId": "str", # Id of the job these details are about. Required. + "position": 0, # Position of the job in question within that queue. + Required. + "queueId": "str", # Id of the queue this job is enqueued in. Required. + "queueLength": 0 # Length of the queue: total number of enqueued jobs. + Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -2850,6 +5852,7 @@ async def unassign_job( content_type: str = "application/json", **kwargs: Any ) -> _models.UnassignJobResult: + # pylint: disable=line-too-long """Unassign a job. Unassign a job. @@ -2863,11 +5866,25 @@ async def unassign_job( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "suspendMatching": bool # Optional. If SuspendMatching is true, then a job + is not queued for re-matching with a worker. + } + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ @overload @@ -2893,11 +5910,19 @@ async def unassign_job( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ @overload @@ -2905,7 +5930,7 @@ async def unassign_job( self, job_id: str, assignment_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2919,15 +5944,23 @@ async def unassign_job( :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request body for unassign route. Default value is None. - :type options: IO + :type options: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ @distributed_trace_async @@ -2935,9 +5968,10 @@ async def unassign_job( self, job_id: str, assignment_id: str, - options: Optional[Union[_models.UnassignJobOptions, JSON, IO]] = None, + options: Optional[Union[_models.UnassignJobOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models.UnassignJobResult: + # pylint: disable=line-too-long """Unassign a job. Unassign a job. @@ -2947,16 +5981,27 @@ async def unassign_job( :param assignment_id: Id of a job assignment. Required. :type assignment_id: str :param options: Request body for unassign route. Is one of the following types: - UnassignJobOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.UnassignJobOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + UnassignJobOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.UnassignJobOptions or JSON or IO[bytes] :return: UnassignJobResult. The UnassignJobResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.UnassignJobResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "suspendMatching": bool # Optional. If SuspendMatching is true, then a job + is not queued for re-matching with a worker. + } + + # response body for status code(s): 200 + response == { + "jobId": "str", # Id of an unassigned job. Required. + "unassignmentCount": 0 # The number of times a job is unassigned. At a + maximum 3. Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -3031,11 +6076,21 @@ async def accept_job_offer(self, worker_id: str, offer_id: str, **kwargs: Any) - :type worker_id: str :param offer_id: Id of an offer. Required. :type offer_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: AcceptJobOfferResult. The AcceptJobOfferResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.AcceptJobOfferResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "assignmentId": "str", # Id of job assignment that assigns a worker that has + accepted an offer to a job. Required. + "jobId": "str", # Id of the job assigned. Required. + "workerId": "str" # Id of the worker that has been assigned this job. + Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -3114,7 +6169,7 @@ async def _decline_job_offer( # pylint: disable=protected-access self, worker_id: str, offer_id: str, - options: Optional[IO] = None, + options: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -3126,9 +6181,10 @@ async def _decline_job_offer( # pylint: disable=protected-access self, worker_id: str, offer_id: str, - options: Optional[Union[_models.DeclineJobOfferOptions, JSON, IO]] = None, + options: Optional[Union[_models.DeclineJobOfferOptions, JSON, IO[bytes]]] = None, **kwargs: Any ) -> _models._models.DeclineJobOfferResult: + # pylint: disable=line-too-long """Declines an offer to work on a job. Declines an offer to work on a job. @@ -3138,16 +6194,25 @@ async def _decline_job_offer( # pylint: disable=protected-access :param offer_id: Id of an offer. Required. :type offer_id: str :param options: Request model for declining offer. Is one of the following types: - DeclineJobOfferOptions, JSON, IO Default value is None. - :type options: ~azure.communication.jobrouter.models.DeclineJobOfferOptions or JSON or IO - :keyword content_type: Body parameter Content-Type. Known values are: application/json. Default - value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. + DeclineJobOfferOptions, JSON, IO[bytes] Default value is None. + :type options: ~azure.communication.jobrouter.models.DeclineJobOfferOptions or JSON or + IO[bytes] :return: DeclineJobOfferResult. The DeclineJobOfferResult is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.DeclineJobOfferResult :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + options = { + "retryOfferAt": "2020-02-20 00:00:00" # Optional. If the RetryOfferAt is not + provided, then this job will not be offered again to the worker who declined this + job unless the worker is de-registered and re-registered. If a RetryOfferAt time + is provided, then the job will be re-matched to eligible workers at the retry + time in UTC. The worker that declined the job will also be eligible for the job + at that time. + } """ error_map = { 401: ClientAuthenticationError, @@ -3216,17 +6281,31 @@ async def _decline_job_offer( # pylint: disable=protected-access @distributed_trace_async async def get_queue_statistics(self, queue_id: str, **kwargs: Any) -> _models.RouterQueueStatistics: + # pylint: disable=line-too-long """Retrieves a queue's statistics. Retrieves a queue's statistics. :param queue_id: Id of the queue to retrieve statistics. Required. :type queue_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterQueueStatistics. The RouterQueueStatistics is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterQueueStatistics :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "length": 0, # Length of the queue: total number of enqueued jobs. Required. + "queueId": "str", # Id of the queue these details are about. Required. + "estimatedWaitTimeMinutes": { + "str": 0.0 # Optional. The estimated wait time of this queue rounded + up to the nearest minute, grouped by job priority. + }, + "longestJobWaitTimeMinutes": 0.0 # Optional. The wait time of the job that + has been enqueued in this queue for the longest. + } """ error_map = { 401: ClientAuthenticationError, @@ -3287,6 +6366,7 @@ async def upsert_worker( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. @@ -3306,11 +6386,136 @@ async def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ @overload @@ -3325,6 +6530,7 @@ async def upsert_worker( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. @@ -3344,18 +6550,81 @@ async def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ @overload async def upsert_worker( self, worker_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -3363,6 +6632,7 @@ async def upsert_worker( match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. @@ -3370,7 +6640,7 @@ async def upsert_worker( :param worker_id: Id of a worker. Required. :type worker_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -3382,33 +6652,97 @@ async def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ @distributed_trace_async async def upsert_worker( self, worker_id: str, - resource: Union[_models.RouterWorker, JSON, IO], + resource: Union[_models.RouterWorker, JSON, IO[bytes]], *, if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.RouterWorker: + # pylint: disable=line-too-long """Creates or updates a worker. Creates or updates a worker. :param worker_id: Id of a worker. Required. :type worker_id: str - :param resource: The resource instance. Is one of the following types: RouterWorker, JSON, IO - Required. - :type resource: ~azure.communication.jobrouter.models.RouterWorker or JSON or IO + :param resource: The resource instance. Is one of the following types: RouterWorker, JSON, + IO[bytes] Required. + :type resource: ~azure.communication.jobrouter.models.RouterWorker or JSON or IO[bytes] :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -3417,13 +6751,136 @@ async def upsert_worker( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :keyword content_type: This request has a JSON Merge Patch body. Default value is None. - :paramtype content_type: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } + + # response body for status code(s): 201, 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -3507,17 +6964,81 @@ async def upsert_worker( @distributed_trace_async async def get_worker(self, worker_id: str, **kwargs: Any) -> _models.RouterWorker: + # pylint: disable=line-too-long """Retrieves an existing worker by Id. Retrieves an existing worker by Id. :param worker_id: Id of a worker. Required. :type worker_id: str - :keyword bool stream: Whether to stream the response of this operation. Defaults to False. You - will have to context manage the returned stream. :return: RouterWorker. The RouterWorker is compatible with MutableMapping :rtype: ~azure.communication.jobrouter.models.RouterWorker :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ error_map = { 401: ClientAuthenticationError, @@ -3624,6 +7145,7 @@ async def delete_worker( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + # https://github.com/Azure/autorest.python/issues/2262 @distributed_trace def list_workers( self, @@ -3634,6 +7156,7 @@ def list_workers( has_capacity: Optional[bool] = None, **kwargs: Any ) -> AsyncItemPaged["_models.RouterWorker"]: + # pylint: disable=line-too-long """Retrieves existing workers. Retrieves existing workers. @@ -3656,6 +7179,71 @@ def list_workers( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.RouterWorker] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "etag": "str", # The entity tag for this resource. Required. + "id": "str", # Id of a worker. Required. + "assignedJobs": [ + { + "assignedAt": "2020-02-20 00:00:00", # The assignment time + of the job in UTC. Required. + "assignmentId": "str", # Id of the assignment. Required. + "capacityCost": 0, # The amount of capacity this assignment + has consumed on the worker. Required. + "jobId": "str" # Id of the job assigned. Required. + } + ], + "availableForOffers": bool, # Optional. A flag indicating this worker is + open to receive offers or not. + "capacity": 0, # Optional. The total capacity score this worker has to + manage multiple concurrent jobs. + "channels": [ + { + "capacityCostPerJob": 0, # The amount of capacity that an + instance of a job of this channel will consume of the total worker + capacity. Required. + "channelId": "str", # Id of a channel. Required. + "maxNumberOfJobs": 0 # Optional. The maximum number of jobs + that can be supported concurrently for this channel. + } + ], + "labels": { + "str": {} # Optional. A set of key/value pairs that are identifying + attributes used by the rules engines to make decisions. Values must be + primitive values - number, string, boolean. + }, + "loadRatio": 0.0, # Optional. A value indicating the workers capacity. A + value of '1' means all capacity is consumed. A value of '0' means no capacity is + currently consumed. + "maxConcurrentOffers": 0, # Optional. If this is set, the worker will only + receive up to this many new offers at a time. + "offers": [ + { + "capacityCost": 0, # The capacity cost consumed by the job + offer. Required. + "jobId": "str", # Id of the job. Required. + "offerId": "str", # Id of an offer. Required. + "expiresAt": "2020-02-20 00:00:00", # Optional. Timestamp + when the offer will expire in UTC. + "offeredAt": "2020-02-20 00:00:00" # Optional. Timestamp + when the offer was created in UTC. + } + ], + "queues": [ + "str" # Optional. Collection of queue(s) that this worker can + receive work from. + ], + "state": "str", # Optional. Current state of a worker. Known values are: + "active", "draining", and "inactive". + "tags": { + "str": {} # Optional. A set of non-identifying attributes attached + to this worker. Values must be primitive values - number, string, boolean. + } + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_patch.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_patch.py index 52c7b592b6d4..0c81e0473cc6 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_patch.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/aio/_operations/_patch.py @@ -76,9 +76,9 @@ async def upsert_exception_policy( # pylint: disable=arguments-differ,unused-ar .. admonition:: Example: - .. literalinclude:: ../samples/exception_policy_crud_ops.py - :start-after: [START update_exception_policy] - :end-before: [END update_exception_policy] + .. literalinclude:: ../samples/exception_policy_crud_ops_async.py + :start-after: [START update_exception_policy_async] + :end-before: [END update_exception_policy_async] :language: python :dedent: 8 :caption: Using a JobRouterAdministrationClient to update an exception policy @@ -164,7 +164,7 @@ async def upsert_exception_policy( async def upsert_exception_policy( self, exception_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -179,7 +179,7 @@ async def upsert_exception_policy( :param exception_policy_id: The Id of the exception policy. Required. :type exception_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -199,7 +199,7 @@ async def upsert_exception_policy( """ async def upsert_exception_policy( - self, exception_policy_id: str, *args: Union[_models.ExceptionPolicy, JSON, IO], **kwargs: Any + self, exception_policy_id: str, *args: Union[_models.ExceptionPolicy, JSON, IO[bytes]], **kwargs: Any ) -> _models.ExceptionPolicy: """Update an exception policy. @@ -227,9 +227,9 @@ async def upsert_exception_policy( .. admonition:: Example: - .. literalinclude:: ../samples/exception_policy_crud_ops.py - :start-after: [START update_exception_policy] - :end-before: [END update_exception_policy] + .. literalinclude:: ../samples/exception_policy_crud_ops_async.py + :start-after: [START update_exception_policy_async] + :end-before: [END update_exception_policy_async] :language: python :dedent: 8 :caption: Using a JobRouterAdministrationClient to update an exception policy @@ -237,7 +237,7 @@ async def upsert_exception_policy( if not exception_policy_id: raise ValueError("exception_policy_id cannot be None.") - exception_policy: Union[_models.ExceptionPolicy, JSON, IO] = _models.ExceptionPolicy() + exception_policy: Union[_models.ExceptionPolicy, JSON, IO[bytes]] = _models.ExceptionPolicy() if len(args) == 1: exception_policy = args[0] @@ -338,9 +338,9 @@ async def upsert_distribution_policy( # pylint: disable=arguments-differ,unused .. admonition:: Example: - .. literalinclude:: ../samples/distribution_policy_crud_ops.py - :start-after: [START update_distribution_policy] - :end-before: [END update_distribution_policy] + .. literalinclude:: ../samples/distribution_policy_crud_ops_async.py + :start-after: [START update_distribution_policy_async] + :end-before: [END update_distribution_policy_async] :language: python :dedent: 8 :caption: Use a JobRouterAdministrationClient to update a distribution policy @@ -426,7 +426,7 @@ async def upsert_distribution_policy( async def upsert_distribution_policy( self, distribution_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -441,7 +441,7 @@ async def upsert_distribution_policy( :param distribution_policy_id: The unique identifier of the policy. Required. :type distribution_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -461,7 +461,7 @@ async def upsert_distribution_policy( """ async def upsert_distribution_policy( - self, distribution_policy_id: str, *args: Union[_models.DistributionPolicy, JSON, IO], **kwargs: Any + self, distribution_policy_id: str, *args: Union[_models.DistributionPolicy, JSON, IO[bytes]], **kwargs: Any ) -> _models.DistributionPolicy: """Update a distribution policy. @@ -492,9 +492,9 @@ async def upsert_distribution_policy( .. admonition:: Example: - .. literalinclude:: ../samples/distribution_policy_crud_ops.py - :start-after: [START update_distribution_policy] - :end-before: [END update_distribution_policy] + .. literalinclude:: ../samples/distribution_policy_crud_ops_async.py + :start-after: [START update_distribution_policy_async] + :end-before: [END update_distribution_policy_async] :language: python :dedent: 8 :caption: Use a JobRouterAdministrationClient to update a distribution policy @@ -502,7 +502,7 @@ async def upsert_distribution_policy( if not distribution_policy_id: raise ValueError("distribution_policy_id cannot be None.") - distribution_policy: Union[_models.DistributionPolicy, JSON, IO] = _models.DistributionPolicy() + distribution_policy: Union[_models.DistributionPolicy, JSON, IO[bytes]] = _models.DistributionPolicy() if len(args) == 1: distribution_policy = args[0] @@ -609,9 +609,9 @@ async def upsert_queue( # pylint: disable=arguments-differ,unused-argument .. admonition:: Example: - .. literalinclude:: ../samples/job_queue_crud_ops.py - :start-after: [START update_queue] - :end-before: [END update_queue] + .. literalinclude:: ../samples/job_queue_crud_ops_async.py + :start-after: [START update_queue_async] + :end-before: [END update_queue_async] :language: python :dedent: 8 :caption: Use a JobRouterAdministrationClient to update a queue @@ -697,7 +697,7 @@ async def upsert_queue( async def upsert_queue( self, queue_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -712,7 +712,7 @@ async def upsert_queue( :param queue_id: The Id of this queue. Required. :type queue_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -732,7 +732,7 @@ async def upsert_queue( """ async def upsert_queue( - self, queue_id: str, *args: Union[_models.RouterQueue, JSON, IO], **kwargs: Any + self, queue_id: str, *args: Union[_models.RouterQueue, JSON, IO[bytes]], **kwargs: Any ) -> _models.RouterQueue: """Update a job queue @@ -765,9 +765,9 @@ async def upsert_queue( .. admonition:: Example: - .. literalinclude:: ../samples/job_queue_crud_ops.py - :start-after: [START update_queue] - :end-before: [END update_queue] + .. literalinclude:: ../samples/job_queue_crud_ops_async.py + :start-after: [START update_queue_async] + :end-before: [END update_queue_async] :language: python :dedent: 8 :caption: Use a JobRouterAdministrationClient to update a queue @@ -775,7 +775,7 @@ async def upsert_queue( if not queue_id: raise ValueError("queue_id cannot be None.") - queue: Union[_models.RouterQueue, JSON, IO] = _models.RouterQueue() + queue: Union[_models.RouterQueue, JSON, IO[bytes]] = _models.RouterQueue() if len(args) == 1: queue = args[0] @@ -924,9 +924,9 @@ async def upsert_classification_policy( # pylint: disable=arguments-differ,unus .. admonition:: Example: - .. literalinclude:: ../samples/classification_policy_crud_ops.py - :start-after: [START update_classification_policy] - :end-before: [END update_classification_policy] + .. literalinclude:: ../samples/classification_policy_crud_ops_async.py + :start-after: [START update_classification_policy_async] + :end-before: [END update_classification_policy_async] :language: python :dedent: 8 :caption: Use a JobRouterAdministrationClient to update a classification policy @@ -1012,7 +1012,7 @@ async def upsert_classification_policy( async def upsert_classification_policy( self, classification_policy_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1027,7 +1027,7 @@ async def upsert_classification_policy( :param classification_policy_id: Unique identifier of this policy. Required. :type classification_policy_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1047,7 +1047,7 @@ async def upsert_classification_policy( """ async def upsert_classification_policy( - self, classification_policy_id: str, *args: Union[_models.ClassificationPolicy, JSON, IO], **kwargs: Any + self, classification_policy_id: str, *args: Union[_models.ClassificationPolicy, JSON, IO[bytes]], **kwargs: Any ) -> _models.ClassificationPolicy: """Update a classification policy @@ -1094,9 +1094,9 @@ async def upsert_classification_policy( .. admonition:: Example: - .. literalinclude:: ../samples/classification_policy_crud_ops.py - :start-after: [START update_classification_policy] - :end-before: [END update_classification_policy] + .. literalinclude:: ../samples/classification_policy_crud_ops_async.py + :start-after: [START update_classification_policy_async] + :end-before: [END update_classification_policy_async] :language: python :dedent: 8 :caption: Use a JobRouterAdministrationClient to update a classification policy @@ -1104,7 +1104,7 @@ async def upsert_classification_policy( if not classification_policy_id: raise ValueError("classification_policy_id cannot be None.") - classification_policy: Union[_models.ClassificationPolicy, JSON, IO] = _models.ClassificationPolicy() + classification_policy: Union[_models.ClassificationPolicy, JSON, IO[bytes]] = _models.ClassificationPolicy() if len(args) == 1: classification_policy = args[0] @@ -1184,6 +1184,7 @@ async def upsert_worker( # pylint: disable=arguments-differ,unused-argument tags: Optional[Dict[str, Union[int, float, str, bool]]], channels: Optional[List[_models.RouterChannel]], available_for_offers: Optional[bool], + max_concurrent_offers: Optional[int], if_unmodified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1214,6 +1215,10 @@ async def upsert_worker( # pylint: disable=arguments-differ,unused-argument :keyword available_for_offers: A flag indicating this worker is open to receive offers or not. :paramtype available_for_offers: Optional[bool] + :keyword max_concurrent_offers: If this is set, the worker will only receive up to this many new + offers at a time. + :paramtype max_concurrent_offers: Optional[int] + :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1229,9 +1234,9 @@ async def upsert_worker( # pylint: disable=arguments-differ,unused-argument .. admonition:: Example: - .. literalinclude:: ../samples/router_worker_crud_ops.py - :start-after: [START update_worker] - :end-before: [END update_worker] + .. literalinclude:: ../samples/router_worker_crud_ops_async.py + :start-after: [START update_worker_async] + :end-before: [END update_worker_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to update a worker @@ -1239,20 +1244,30 @@ async def upsert_worker( # pylint: disable=arguments-differ,unused-argument .. admonition:: Example: .. literalinclude:: ../samples/router_worker_crud_ops.py - :start-after: [START register_worker] - :end-before: [END register_worker] + :start-after: [START register_worker_async] + :end-before: [END register_worker_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to register a worker .. admonition:: Example: - .. literalinclude:: ../samples/router_worker_crud_ops.py - :start-after: [START deregister_worker] - :end-before: [END deregister_worker] + .. literalinclude:: ../samples/router_worker_crud_ops_async.py + :start-after: [START deregister_worker_async] + :end-before: [END deregister_worker_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to de-register a worker + + .. admonition:: Example: + + .. literalinclude:: ../samples/router_worker_crud_ops_async.py + :start-after: [START create_worker_w_limit_concurrent_offers_async] + :end-before: [END create_worker_w_limit_concurrent_offers_async] + :language: python + :dedent: 8 + :caption: Use a JobRouterClient to create a worker with concurrent offer limit + """ @overload @@ -1335,7 +1350,7 @@ async def upsert_worker( async def upsert_worker( self, worker_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1350,7 +1365,7 @@ async def upsert_worker( :param worker_id: Id of the worker. Required. :type worker_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1370,7 +1385,7 @@ async def upsert_worker( """ async def upsert_worker( - self, worker_id: str, *args: Union[_models.RouterWorker, JSON, IO], **kwargs: Any + self, worker_id: str, *args: Union[_models.RouterWorker, JSON, IO[bytes]], **kwargs: Any ) -> _models.RouterWorker: """Update a router worker. @@ -1397,6 +1412,10 @@ async def upsert_worker( :keyword available_for_offers: A flag indicating this worker is open to receive offers or not. :paramtype available_for_offers: Optional[bool] + :keyword max_concurrent_offers: If this is set, the worker will only receive up to this many new + offers at a time. + :paramtype max_concurrent_offers: Optional[int] + :keyword if_unmodified_since: The request should only proceed if the entity was not modified after this time. Default value is None. :paramtype if_unmodified_since: ~datetime.datetime @@ -1412,27 +1431,27 @@ async def upsert_worker( .. admonition:: Example: - .. literalinclude:: ../samples/router_worker_crud_ops.py - :start-after: [START update_worker] - :end-before: [END update_worker] + .. literalinclude:: ../samples/router_worker_crud_ops_async.py + :start-after: [START update_worker_async] + :end-before: [END update_worker_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to update a worker .. admonition:: Example: - .. literalinclude:: ../samples/router_worker_crud_ops.py - :start-after: [START register_worker] - :end-before: [END register_worker] + .. literalinclude:: ../samples/router_worker_crud_ops_async.py + :start-after: [START register_worker_async] + :end-before: [END register_worker_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to register a worker .. admonition:: Example: - .. literalinclude:: ../samples/router_worker_crud_ops.py - :start-after: [START deregister_worker] - :end-before: [END deregister_worker] + .. literalinclude:: ../samples/router_worker_crud_ops_async.py + :start-after: [START deregister_worker_async] + :end-before: [END deregister_worker_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to de-register a worker @@ -1440,7 +1459,7 @@ async def upsert_worker( if not worker_id: raise ValueError("worker_id cannot be None.") - router_worker: Union[_models.RouterWorker, JSON, IO] = _models.RouterWorker() + router_worker: Union[_models.RouterWorker, JSON, IO[bytes]] = _models.RouterWorker() if len(args) == 1: router_worker = args[0] @@ -1453,6 +1472,7 @@ async def upsert_worker( tags=kwargs.pop("tags", router_worker.tags), channels=kwargs.pop("channels", router_worker.channels), available_for_offers=kwargs.pop("available_for_offers", router_worker.available_for_offers), + max_concurrent_offers=kwargs.pop("max_concurrent_offers", router_worker.max_concurrent_offers), ) if_unmodified_since = kwargs.pop("if_unmodified_since", None) @@ -1610,9 +1630,9 @@ async def upsert_job( # pylint: disable=arguments-differ,unused-argument .. admonition:: Example: - .. literalinclude:: ../samples/router_job_crud_ops.py - :start-after: [START update_job] - :end-before: [END update_job] + .. literalinclude:: ../samples/router_job_crud_ops_async.py + :start-after: [START update_job_async] + :end-before: [END update_job_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to update a job @@ -1698,7 +1718,7 @@ async def upsert_job( async def upsert_job( self, job_id: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/merge-patch+json", if_unmodified_since: Optional[datetime.datetime] = None, @@ -1713,7 +1733,7 @@ async def upsert_job( :param job_id: The id of the job. Required. :type job_id: str :param resource: The resource instance. Required. - :type resource: IO + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1733,7 +1753,7 @@ async def upsert_job( """ async def upsert_job( - self, job_id: str, *args: Union[_models.RouterJob, JSON, IO], **kwargs: Any + self, job_id: str, *args: Union[_models.RouterJob, JSON, IO[bytes]], **kwargs: Any ) -> _models.RouterJob: """Update a job. @@ -1791,9 +1811,9 @@ async def upsert_job( .. admonition:: Example: - .. literalinclude:: ../samples/router_job_crud_ops.py - :start-after: [START update_job] - :end-before: [END update_job] + .. literalinclude:: ../samples/router_job_crud_ops_async.py + :start-after: [START update_job_async] + :end-before: [END update_job_async] :language: python :dedent: 8 :caption: Use a JobRouterClient to update a job @@ -1801,7 +1821,7 @@ async def upsert_job( if not job_id: raise ValueError("job_id cannot be None.") - router_job: Union[_models.RouterJob, JSON, IO] = _models.RouterJob() + router_job: Union[_models.RouterJob, JSON, IO[bytes]] = _models.RouterJob() if len(args) == 1: router_job = args[0] diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_enums.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_enums.py index 48213ad16d18..dfa3514a122b 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_enums.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_enums.py @@ -151,7 +151,7 @@ class RouterJobStatusSelector(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Job is in a suspended state and waiting for an update.""" ACTIVE = "active" """Job is in a state of PendingClassification or Queued or Assigned or ClassificationFailed or - #: Completed or PendingSchedule or Scheduled or ScheduleFailed or WaitingForActivation.""" + Completed or PendingSchedule or Scheduled or ScheduleFailed or WaitingForActivation.""" class RouterRuleKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -185,7 +185,7 @@ class RouterWorkerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Worker is active and available to take offers.""" DRAINING = "draining" """Worker is not active, if there are existing offers they are being revoked. No new offers are - #: sent.""" + sent.""" INACTIVE = "inactive" """Worker is not active. No new offers are sent.""" @@ -197,7 +197,7 @@ class RouterWorkerStateSelector(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Worker is active and available to take offers.""" DRAINING = "draining" """Worker is not active, if there are existing offers they are being revoked. No new offers are - #: sent.""" + sent.""" INACTIVE = "inactive" """Worker is not active. No new offers are sent.""" ALL = "all" @@ -211,7 +211,7 @@ class ScoringRuleParameterSelector(str, Enum, metaclass=CaseInsensitiveEnumMeta) """Parameter to add job labels to scoring payload. Property is sent as ``job``.""" WORKER_SELECTORS = "workerSelectors" """Parameter to add worker selectors from a job to scoring payload. Property is sent as - #: ``selectors``.""" + ``selectors``.""" class WorkerSelectorAttachmentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_models.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_models.py index 68689b307e12..746ee8a85300 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_models.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/models/_models.py @@ -8,8 +8,7 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload +from typing import Any, Dict, List, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload from .. import _model_base from .._model_base import rest_discriminator, rest_field @@ -23,11 +22,6 @@ WorkerSelectorAttachmentKind, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -98,6 +92,7 @@ class DistributionMode(_model_base.Model): values are: "bestWorker", "longestIdle", and "roundRobin". :vartype kind: str or ~azure.communication.jobrouter.models.DistributionModeKind """ + __mapping__: Dict[str, _model_base.Model] = {} min_concurrent_offers: Optional[int] = rest_field(name="minConcurrentOffers") """Governs the minimum desired number of active concurrent offers a job can have.""" @@ -108,7 +103,7 @@ class DistributionMode(_model_base.Model): selectors. Warning: You may get workers that are not qualified for a job they are matched with if you set this variable to true. This flag is intended more for temporary usage. By default, set to false.""" - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of DistributionMode. Required. Known values are: \"bestWorker\", \"longestIdle\", and \"roundRobin\".""" @@ -116,6 +111,7 @@ class DistributionMode(_model_base.Model): def __init__( self, *, + kind: str, min_concurrent_offers: Optional[int] = None, max_concurrent_offers: Optional[int] = None, bypass_selectors: Optional[bool] = None, @@ -129,9 +125,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class BestWorkerMode(DistributionMode, discriminator="bestWorker"): @@ -193,9 +188,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[DistributionModeKind.BEST_WORKER] = DistributionModeKind.BEST_WORKER + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=DistributionModeKind.BEST_WORKER, **kwargs) class ExceptionAction(_model_base.Model): @@ -216,7 +210,7 @@ class ExceptionAction(_model_base.Model): __mapping__: Dict[str, _model_base.Model] = {} id: Optional[str] = rest_field() """Unique Id of the exception action.""" - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of ExceptionAction. Required. Known values are: \"cancel\", \"manualReclassify\", and \"reclassify\".""" @@ -224,6 +218,7 @@ class ExceptionAction(_model_base.Model): def __init__( self, *, + kind: str, id: Optional[str] = None, # pylint: disable=redefined-builtin ): ... @@ -235,9 +230,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class CancelExceptionAction(ExceptionAction, discriminator="cancel"): @@ -283,9 +277,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ExceptionActionKind.CANCEL] = ExceptionActionKind.CANCEL + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=ExceptionActionKind.CANCEL, **kwargs) class CancelJobOptions(_model_base.Model): @@ -498,13 +491,27 @@ class QueueSelectorAttachment(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of QueueSelectorAttachment. Required. Known values are: \"conditional\", \"passThrough\", \"ruleEngine\", \"static\", and \"weightedAllocation\".""" - def __init__(self, *args: Any, **kwargs: Any) -> None: + @overload + def __init__( + self, + *, + kind: str, + ): + ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class ConditionalQueueSelectorAttachment(QueueSelectorAttachment, discriminator="conditional"): @@ -547,9 +554,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[QueueSelectorAttachmentKind.CONDITIONAL] = QueueSelectorAttachmentKind.CONDITIONAL + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=QueueSelectorAttachmentKind.CONDITIONAL, **kwargs) class WorkerSelectorAttachment(_model_base.Model): @@ -569,14 +575,28 @@ class WorkerSelectorAttachment(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of WorkerSelectorAttachment. Required. Known values are: \"conditional\", \"passThrough\", \"ruleEngine\", \"static\", and \"weightedAllocation\".""" - def __init__(self, *args: Any, **kwargs: Any) -> None: + @overload + def __init__( + self, + *, + kind: str, + ): + ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class ConditionalWorkerSelectorAttachment(WorkerSelectorAttachment, discriminator="conditional"): @@ -619,9 +639,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[WorkerSelectorAttachmentKind.CONDITIONAL] = WorkerSelectorAttachmentKind.CONDITIONAL + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=WorkerSelectorAttachmentKind.CONDITIONAL, **kwargs) class DeclineJobOfferOptions(_model_base.Model): @@ -686,13 +705,27 @@ class RouterRule(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of RouterRule. Required. Known values are: \"directMap\", \"expression\", \"function\", \"static\", and \"webhook\".""" - def __init__(self, *args: Any, **kwargs: Any) -> None: + @overload + def __init__( + self, + *, + kind: str, + ): + ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class DirectMapRouterRule(RouterRule, discriminator="directMap"): @@ -709,10 +742,6 @@ class DirectMapRouterRule(RouterRule, discriminator="directMap"): """The type discriminator describing a sub-type of Rule. Required. Discriminator value for DirectMapRouterRule.""" - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[RouterRuleKind.DIRECT_MAP] = RouterRuleKind.DIRECT_MAP - class DistributionPolicy(_model_base.Model): """Policy governing how jobs are distributed to workers. @@ -867,13 +896,27 @@ class ExceptionTrigger(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of ExceptionTrigger. Required. Known values are: \"queueLength\" and \"waitTime\".""" - def __init__(self, *args: Any, **kwargs: Any) -> None: + @overload + def __init__( + self, + *, + kind: str, + ): + ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class ExpressionRouterRule(RouterRule, discriminator="expression"): @@ -915,9 +958,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[RouterRuleKind.EXPRESSION] = RouterRuleKind.EXPRESSION + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=RouterRuleKind.EXPRESSION, **kwargs) class FunctionRouterRule(RouterRule, discriminator="function"): @@ -958,9 +1000,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[RouterRuleKind.FUNCTION] = RouterRuleKind.FUNCTION + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=RouterRuleKind.FUNCTION, **kwargs) class FunctionRouterRuleCredential(_model_base.Model): @@ -1025,13 +1066,27 @@ class JobMatchingMode(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal[None] = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind") """The type discriminator describing a sub-type of JobMatchingMode. Required. Known values are: \"queueAndMatch\", \"scheduleAndSuspend\", and \"suspend\".""" - def __init__(self, *args: Any, **kwargs: Any) -> None: + @overload + def __init__( + self, + *, + kind: str, + ): + ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation super().__init__(*args, **kwargs) - self.kind: Literal[None] = None class LongestIdleMode(DistributionMode, discriminator="longestIdle"): @@ -1076,9 +1131,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[DistributionModeKind.LONGEST_IDLE] = DistributionModeKind.LONGEST_IDLE + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=DistributionModeKind.LONGEST_IDLE, **kwargs) class ManualReclassifyExceptionAction(ExceptionAction, discriminator="manualReclassify"): @@ -1128,9 +1182,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ExceptionActionKind.MANUAL_RECLASSIFY] = ExceptionActionKind.MANUAL_RECLASSIFY + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=ExceptionActionKind.MANUAL_RECLASSIFY, **kwargs) class OAuth2WebhookClientCredential(_model_base.Model): @@ -1211,9 +1264,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[QueueSelectorAttachmentKind.PASS_THROUGH] = QueueSelectorAttachmentKind.PASS_THROUGH + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=QueueSelectorAttachmentKind.PASS_THROUGH, **kwargs) class PassThroughWorkerSelectorAttachment(WorkerSelectorAttachment, discriminator="passThrough"): @@ -1265,9 +1317,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[WorkerSelectorAttachmentKind.PASS_THROUGH] = WorkerSelectorAttachmentKind.PASS_THROUGH + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=WorkerSelectorAttachmentKind.PASS_THROUGH, **kwargs) class QueueAndMatchMode(JobMatchingMode, discriminator="queueAndMatch"): @@ -1285,10 +1336,6 @@ class QueueAndMatchMode(JobMatchingMode, discriminator="queueAndMatch"): """The type discriminator describing QueueAndMatchMode. Required. Discriminator value for QueueAndMatchMode.""" - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[JobMatchingModeKind.QUEUE_AND_MATCH] = JobMatchingModeKind.QUEUE_AND_MATCH - class QueueLengthExceptionTrigger(ExceptionTrigger, discriminator="queueLength"): """Trigger for an exception action on exceeding queue length. @@ -1324,9 +1371,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ExceptionTriggerKind.QUEUE_LENGTH] = ExceptionTriggerKind.QUEUE_LENGTH + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=ExceptionTriggerKind.QUEUE_LENGTH, **kwargs) class QueueWeightedAllocation(_model_base.Model): @@ -1411,9 +1457,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ExceptionActionKind.RECLASSIFY] = ExceptionActionKind.RECLASSIFY + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=ExceptionActionKind.RECLASSIFY, **kwargs) class ReclassifyJobOptions(_model_base.Model): @@ -1467,9 +1512,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[DistributionModeKind.ROUND_ROBIN] = DistributionModeKind.ROUND_ROBIN + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=DistributionModeKind.ROUND_ROBIN, **kwargs) class RouterChannel(_model_base.Model): @@ -2031,6 +2075,9 @@ class RouterWorker(_model_base.Model): # pylint: disable=too-many-instance-attr :vartype load_ratio: float :ivar available_for_offers: A flag indicating this worker is open to receive offers or not. :vartype available_for_offers: bool + :ivar max_concurrent_offers: If this is set, the worker will only receive up to this many new + offers at a time. + :vartype max_concurrent_offers: int """ etag: str = rest_field(visibility=["read"]) @@ -2062,6 +2109,8 @@ class RouterWorker(_model_base.Model): # pylint: disable=too-many-instance-attr of '0' means no capacity is currently consumed.""" available_for_offers: Optional[bool] = rest_field(name="availableForOffers") """A flag indicating this worker is open to receive offers or not.""" + max_concurrent_offers: Optional[int] = rest_field(name="maxConcurrentOffers") + """If this is set, the worker will only receive up to this many new offers at a time.""" @overload def __init__( @@ -2073,6 +2122,7 @@ def __init__( tags: Optional[Dict[str, Any]] = None, channels: Optional[List["_models.RouterChannel"]] = None, available_for_offers: Optional[bool] = None, + max_concurrent_offers: Optional[int] = None, ): ... @@ -2234,9 +2284,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[QueueSelectorAttachmentKind.RULE_ENGINE] = QueueSelectorAttachmentKind.RULE_ENGINE + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=QueueSelectorAttachmentKind.RULE_ENGINE, **kwargs) class RuleEngineWorkerSelectorAttachment(WorkerSelectorAttachment, discriminator="ruleEngine"): @@ -2272,9 +2321,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[WorkerSelectorAttachmentKind.RULE_ENGINE] = WorkerSelectorAttachmentKind.RULE_ENGINE + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=WorkerSelectorAttachmentKind.RULE_ENGINE, **kwargs) class ScheduleAndSuspendMode(JobMatchingMode, discriminator="scheduleAndSuspend"): @@ -2311,9 +2359,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[JobMatchingModeKind.SCHEDULE_AND_SUSPEND] = JobMatchingModeKind.SCHEDULE_AND_SUSPEND + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=JobMatchingModeKind.SCHEDULE_AND_SUSPEND, **kwargs) class ScoringRuleOptions(_model_base.Model): @@ -2408,9 +2455,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[QueueSelectorAttachmentKind.STATIC] = QueueSelectorAttachmentKind.STATIC + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=QueueSelectorAttachmentKind.STATIC, **kwargs) class StaticRouterRule(RouterRule, discriminator="static"): @@ -2448,9 +2494,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[RouterRuleKind.STATIC] = RouterRuleKind.STATIC + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=RouterRuleKind.STATIC, **kwargs) class StaticWorkerSelectorAttachment(WorkerSelectorAttachment, discriminator="static"): @@ -2486,9 +2531,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[WorkerSelectorAttachmentKind.STATIC] = WorkerSelectorAttachmentKind.STATIC + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=WorkerSelectorAttachmentKind.STATIC, **kwargs) class SuspendMode(JobMatchingMode, discriminator="suspend"): @@ -2504,10 +2548,6 @@ class SuspendMode(JobMatchingMode, discriminator="suspend"): kind: Literal[JobMatchingModeKind.SUSPEND] = rest_discriminator(name="kind") # type: ignore """The type discriminator describing SuspendMode. Required. Discriminator value for SuspendMode.""" - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[JobMatchingModeKind.SUSPEND] = JobMatchingModeKind.SUSPEND - class UnassignJobOptions(_model_base.Model): """Request payload for unassigning a job. @@ -2608,9 +2648,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ExceptionTriggerKind.WAIT_TIME] = ExceptionTriggerKind.WAIT_TIME + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=ExceptionTriggerKind.WAIT_TIME, **kwargs) class WebhookRouterRule(RouterRule, discriminator="webhook"): @@ -2658,12 +2697,13 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[RouterRuleKind.WEBHOOK] = RouterRuleKind.WEBHOOK + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=RouterRuleKind.WEBHOOK, **kwargs) -class WeightedAllocationQueueSelectorAttachment(QueueSelectorAttachment, discriminator="weightedAllocation"): +class WeightedAllocationQueueSelectorAttachment( + QueueSelectorAttachment, discriminator="weightedAllocation" +): # pylint: disable=name-too-long """Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting. @@ -2697,14 +2737,13 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ - QueueSelectorAttachmentKind.WEIGHTED_ALLOCATION - ] = QueueSelectorAttachmentKind.WEIGHTED_ALLOCATION + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=QueueSelectorAttachmentKind.WEIGHTED_ALLOCATION, **kwargs) -class WeightedAllocationWorkerSelectorAttachment(WorkerSelectorAttachment, discriminator="weightedAllocation"): +class WeightedAllocationWorkerSelectorAttachment( + WorkerSelectorAttachment, discriminator="weightedAllocation" +): # pylint: disable=name-too-long """Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting. @@ -2738,11 +2777,8 @@ def __init__(self, mapping: Mapping[str, Any]): :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - self.kind: Literal[ - WorkerSelectorAttachmentKind.WEIGHTED_ALLOCATION - ] = WorkerSelectorAttachmentKind.WEIGHTED_ALLOCATION + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, kind=WorkerSelectorAttachmentKind.WEIGHTED_ALLOCATION, **kwargs) class WorkerWeightedAllocation(_model_base.Model): diff --git a/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops.py b/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops.py index fb135b2045cd..5b639ed2dcc1 100644 --- a/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops.py +++ b/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops.py @@ -108,6 +108,42 @@ def create_worker(self): # [END create_worker] + def create_worker_w_limit_concurrent_offers(self): + connection_string = self.endpoint + worker_id = self._worker_id + # [START create_worker_w_limit_concurrent_offers] + from azure.communication.jobrouter import ( + JobRouterClient, + ) + from azure.communication.jobrouter.models import ( + RouterWorker, + RouterChannel, + ) + + # set `connection_string` to an existing ACS endpoint + router_client = JobRouterClient.from_connection_string(conn_str=connection_string) + print("JobRouterClient created successfully!") + + router_worker: RouterWorker = router_client.upsert_worker( + worker_id, + RouterWorker( + capacity=100, + queues=["worker-q-1", "worker-q-2"], + channels=[ + RouterChannel(channel_id="WebChat", capacity_cost_per_job=1), + RouterChannel(channel_id="WebChatEscalated", capacity_cost_per_job=20), + RouterChannel(channel_id="Voip", capacity_cost_per_job=100), + ], + labels={"Location": "NA", "English": 7, "O365": True, "Xbox_Support": False}, + tags={"Name": "John Doe", "Department": "IT_HelpDesk"}, + max_concurrent_offers=1, + ), + ) + + print(f"Router worker successfully created with id: {router_worker.id}") + + # [END create_worker_w_limit_concurrent_offers] + def update_worker(self): connection_string = self.endpoint worker_id = self._worker_id @@ -235,6 +271,7 @@ def clean_up(self): sample.setup_distribution_policy() sample.setup_queues() sample.create_worker() + sample.create_worker_w_limit_concurrent_offers() sample.update_worker() sample.get_worker() sample.register_worker() diff --git a/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops_async.py b/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops_async.py index 1dd1c797bbc9..58ca6d76ff70 100644 --- a/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops_async.py +++ b/sdk/communication/azure-communication-jobrouter/samples/router_worker_crud_ops_async.py @@ -112,6 +112,41 @@ async def create_worker(self): # [END create_worker_async] + async def create_worker_w_limit_concurrent_offers(self): + connection_string = self.endpoint + worker_id = self._worker_id + # [START create_worker_w_limit_concurrent_offers_async] + from azure.communication.jobrouter.aio import JobRouterClient + from azure.communication.jobrouter.models import ( + RouterWorker, + RouterChannel, + ) + + # set `connection_string` to an existing ACS endpoint + router_client = JobRouterClient.from_connection_string(conn_str=connection_string) + print("JobRouterClient created successfully!") + + async with router_client: + router_worker: RouterWorker = await router_client.upsert_worker( + worker_id, + RouterWorker( + capacity=100, + queues=["worker-q-1", "worker-q-2"], + channels=[ + RouterChannel(channel_id="WebChat", capacity_cost_per_job=1), + RouterChannel(channel_id="WebChatEscalated", capacity_cost_per_job=20), + RouterChannel(channel_id="Voip", capacity_cost_per_job=100), + ], + labels={"Location": "NA", "English": 7, "O365": True, "Xbox_Support": False}, + tags={"Name": "John Doe", "Department": "IT_HelpDesk"}, + max_concurrent_offers = 1, + ), + ) + + print(f"Router worker successfully created with id: {router_worker.id}") + + # [END create_worker_w_limit_concurrent_offers_async] + async def update_worker(self): connection_string = self.endpoint worker_id = self._worker_id @@ -247,6 +282,7 @@ async def main(): await sample.setup_distribution_policy() await sample.setup_queues() await sample.create_worker() + await sample.create_worker_w_limit_concurrent_offers() await sample.update_worker() await sample.get_worker() await sample.register_worker() diff --git a/sdk/communication/azure-communication-jobrouter/setup.py b/sdk/communication/azure-communication-jobrouter/setup.py index c963bd8c05ae..02e082ea74ff 100644 --- a/sdk/communication/azure-communication-jobrouter/setup.py +++ b/sdk/communication/azure-communication-jobrouter/setup.py @@ -38,15 +38,15 @@ url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", keywords="azure, azure sdk", classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -64,8 +64,8 @@ }, install_requires=[ "isodate<1.0.0,>=0.6.1", - "azure-core<2.0.0,>=1.28.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "azure-core<2.0.0,>=1.30.0", + "typing-extensions>=4.6.0", ], - python_requires=">=3.7", + python_requires=">=3.8", ) diff --git a/sdk/communication/azure-communication-jobrouter/tests/_validators.py b/sdk/communication/azure-communication-jobrouter/tests/_validators.py index 1606c50a37e1..c9d8827793c9 100644 --- a/sdk/communication/azure-communication-jobrouter/tests/_validators.py +++ b/sdk/communication/azure-communication-jobrouter/tests/_validators.py @@ -594,6 +594,10 @@ def validate_worker_availability( else: assert entity.state == RouterWorkerState.DRAINING or entity.state == RouterWorkerState.INACTIVE + @staticmethod + def validate_max_concurrent_offers(entity, max_concurrent_offers, **kwargs): + assert entity.max_concurrent_offers == max_concurrent_offers + @staticmethod def validate_worker(worker, **kwargs): if "identifier" in kwargs: @@ -617,6 +621,9 @@ def validate_worker(worker, **kwargs): if "available_for_offers" in kwargs: RouterWorkerValidator.validate_worker_availability(worker, kwargs.pop("available_for_offers")) + if "max_concurrent_offers" in kwargs: + RouterWorkerValidator.validate_max_concurrent_offers(worker, kwargs.pop("max_concurrent_offers")) + class RouterJobValidator(object): @staticmethod diff --git a/sdk/communication/azure-communication-jobrouter/tests/test_limit_concurrent_offer_worker_scenario.py b/sdk/communication/azure-communication-jobrouter/tests/test_limit_concurrent_offer_worker_scenario.py new file mode 100644 index 000000000000..cf5162bb2e0b --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/tests/test_limit_concurrent_offer_worker_scenario.py @@ -0,0 +1,287 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from datetime import datetime +import pytest +from devtools_testutils import recorded_by_proxy +from azure.core.exceptions import ( + HttpResponseError, +) +from _router_test_case import RouterRecordedTestCase + +from _decorators import RouterPreparers + +from azure.communication.jobrouter import ( + JobRouterClient, + JobRouterAdministrationClient, +) +from azure.communication.jobrouter.models import ( + LongestIdleMode, + RouterChannel, + RouterJobStatus, + RouterWorker, + RouterJobOffer, + AcceptJobOfferResult, + UnassignJobResult, + RouterJob, + RouterJobAssignment, + RouterWorkerState, + DistributionPolicy, + RouterQueue, + DeclineJobOfferOptions, + CompleteJobOptions, + CloseJobOptions, +) + +channel_id = "fakeChannel2" + + +# The test class name needs to start with "Test" to get collected by pytest +class TestLimitConcurrentOffersToWorkerScenario(RouterRecordedTestCase): + def clean_up(self, **kwargs): + # delete in live mode + if not self.is_playback(): + router_admin_client: JobRouterAdministrationClient = self.create_admin_client() + router_client: JobRouterClient = self.create_client() + + if self._testMethodName in self.job_ids and any(self.job_ids[self._testMethodName]): + for _id in set(self.job_ids[self._testMethodName]): + self.clean_up_job(job_id=_id, suppress_errors=True) + + if self._testMethodName in self.worker_ids and any(self.worker_ids[self._testMethodName]): + for _id in set(self.worker_ids[self._testMethodName]): + # delete worker + router_client.delete_worker(_id) + + if self._testMethodName in self.classification_policy_ids and any( + self.classification_policy_ids[self._testMethodName] + ): + for policy_id in set(self.classification_policy_ids[self._testMethodName]): + router_admin_client.delete_classification_policy(policy_id) + + if self._testMethodName in self.queue_ids and any(self.queue_ids[self._testMethodName]): + for policy_id in set(self.queue_ids[self._testMethodName]): + router_admin_client.delete_queue(policy_id) + + if self._testMethodName in self.distribution_policy_ids and any( + self.distribution_policy_ids[self._testMethodName] + ): + for policy_id in set(self.distribution_policy_ids[self._testMethodName]): + router_admin_client.delete_distribution_policy(policy_id) + + def get_distribution_policy_id(self, **kwargs): + return "_" + self._testMethodName + "_tst_dp" + + def setup_distribution_policy(self, **kwargs): + client: JobRouterAdministrationClient = self.create_admin_client() + distribution_policy_id = self.get_distribution_policy_id() + + policy: DistributionPolicy = DistributionPolicy( + offer_expires_after_seconds=10.0 * 60, + mode=LongestIdleMode(min_concurrent_offers=1, max_concurrent_offers=1), + name="test", + ) + + distribution_policy = client.upsert_distribution_policy(distribution_policy_id, policy) + + # add for cleanup later + if self._testMethodName in self.distribution_policy_ids: + self.distribution_policy_ids[self._testMethodName] = self.distribution_policy_ids[ + self._testMethodName + ].append(distribution_policy_id) + else: + self.distribution_policy_ids[self._testMethodName] = [distribution_policy_id] + + def get_job_queue_id(self, **kwargs): + return "_" + self._testMethodName + "_tst_q" + + def setup_job_queue(self, **kwargs): + client: JobRouterAdministrationClient = self.create_admin_client() + job_queue_id = self.get_job_queue_id() + + job_queue: RouterQueue = RouterQueue(distribution_policy_id=self.get_distribution_policy_id(), name="test") + + job_queue = client.upsert_queue(job_queue_id, job_queue) + + # add for cleanup later + if self._testMethodName in self.queue_ids: + self.queue_ids[self._testMethodName] = self.queue_ids[self._testMethodName].append(job_queue_id) + else: + self.queue_ids[self._testMethodName] = [job_queue_id] + + def get_router_worker_id(self, **kwargs): + return "_" + self._testMethodName + "_tst_w" + + def setup_router_worker(self, **kwargs): + w_identifier = self.get_router_worker_id() + router_client: JobRouterClient = self.create_client() + worker_queues = [self.get_job_queue_id()] + worker_channels = [RouterChannel(channel_id=channel_id, capacity_cost_per_job=1)] + + worker: RouterWorker = RouterWorker( + capacity=10, + queues=worker_queues, + channels=worker_channels, + available_for_offers=True, + max_concurrent_offers=1, + ) + + router_worker = router_client.upsert_worker(w_identifier, worker) + + # add for cleanup + self.worker_ids[self._testMethodName] = [w_identifier] + + def validate_job_is_queued(self, identifier, **kwargs): + router_client: JobRouterClient = self.create_client() + router_job = router_client.get_job(identifier) + assert router_job.status == RouterJobStatus.QUEUED + + def validate_worker_has_offer( + self, + worker_id, # type: str + job_ids, # type: List[str] + **kwargs, # type: Any + ): + router_client: JobRouterClient = self.create_client() + router_worker: RouterWorker = router_client.get_worker(worker_id) + offer_for_jobs = [job_offer for job_offer in router_worker.offers if job_offer.job_id in job_ids] + assert any(offer_for_jobs) + + def validate_worker_deregistration( # cSpell:disable-line + self, + worker_id, # type: str + **kwargs, # type: Any + ): + router_client: JobRouterClient = self.create_client() + router_worker: RouterWorker = router_client.get_worker(worker_id) + assert router_worker.state == RouterWorkerState.INACTIVE + + @RouterPreparers.router_test_decorator + @recorded_by_proxy + @RouterPreparers.before_test_execute("setup_distribution_policy") + @RouterPreparers.before_test_execute("setup_job_queue") + @RouterPreparers.before_test_execute("setup_router_worker") + @RouterPreparers.after_test_execute("clean_up") + def test_limit_concurrent_offer_to_worker_scenario(self, **kwargs): + router_client: JobRouterClient = self.create_client() + + # create job + job_identifier_1 = f"concurrent_offer_worker_scenario_job_id_1" + job_identifier_2 = f"concurrent_offer_worker_scenario_job_id_2" + job_ids = [job_identifier_1, job_identifier_2] + + router_job_1: RouterJob = RouterJob( + channel_id=channel_id, + queue_id=self.get_job_queue_id(), + priority=1, + ) + router_job_1: RouterJob = router_client.upsert_job(job_identifier_1, router_job_1) + + # add for cleanup + self.job_ids[self._testMethodName] = [job_identifier_1] + + assert router_job_1 is not None + + # validate there are offers made + self._poll_until_no_exception( + self.validate_worker_has_offer, AssertionError, self.get_router_worker_id(), job_ids + ) + + router_job_2: RouterJob = RouterJob( + channel_id=channel_id, + queue_id=self.get_job_queue_id(), + priority=1, + ) + router_job_2: RouterJob = router_client.upsert_job(job_identifier_2, router_job_2) + + # add for cleanup + self.job_ids[self._testMethodName].append(job_identifier_2) + + assert router_job_2 is not None + + # validate there are still offers + self._poll_until_no_exception( + self.validate_worker_has_offer, AssertionError, self.get_router_worker_id(), job_ids + ) + + router_worker = router_client.get_worker(self.get_router_worker_id()) + job_offers = [job_offer for job_offer in router_worker.offers if job_offer.job_id in job_ids] + + assert len(job_offers) == 1 + job_offer_1: RouterJobOffer = job_offers[0] + assert job_offer_1.capacity_cost == 1 + assert job_offer_1.offered_at is not None + assert job_offer_1.expires_at is not None + job_without_offer: str = job_identifier_2 if job_offer_1.job_id == job_identifier_1 else job_identifier_1 + + # accept job offer + offer_id_1: str = job_offer_1.offer_id + accept_job_offer_result_1: AcceptJobOfferResult = router_client.accept_job_offer( + worker_id=self.get_router_worker_id(), offer_id=offer_id_1 + ) + + assert accept_job_offer_result_1.job_id == job_offer_1.job_id + assert accept_job_offer_result_1.worker_id == self.get_router_worker_id() + + # check for new offers sent to worker now that previous offer has been accepted + self._poll_until_no_exception( + self.validate_worker_has_offer, AssertionError, self.get_router_worker_id(), [job_without_offer] + ) + + router_worker = router_client.get_worker(self.get_router_worker_id()) + job_offers = [job_offer for job_offer in router_worker.offers if job_offer.job_id == job_without_offer] + + assert len(job_offers) == 1 + job_offer_2: RouterJobOffer = job_offers[0] + assert job_offer_2.capacity_cost == 1 + assert job_offer_2.offered_at is not None + assert job_offer_2.expires_at is not None + + # accept job offer + offer_id_2 = job_offer_2.offer_id + accept_job_offer_result_2: AcceptJobOfferResult = router_client.accept_job_offer( + worker_id=self.get_router_worker_id(), offer_id=offer_id_2 + ) + + assert accept_job_offer_result_2.job_id == job_without_offer + assert accept_job_offer_result_2.worker_id == self.get_router_worker_id() + + # complete both jobs + router_client.complete_job(accept_job_offer_result_1.job_id, accept_job_offer_result_1.assignment_id) + router_client.complete_job(accept_job_offer_result_2.job_id, accept_job_offer_result_2.assignment_id) + + # close both jobs + router_client.close_job(accept_job_offer_result_1.job_id, accept_job_offer_result_1.assignment_id) + router_client.close_job(accept_job_offer_result_2.job_id, accept_job_offer_result_2.assignment_id) + + # validate post closure job details + queried_job_1: RouterJob = router_client.get_job(job_identifier_1) + queried_job_2: RouterJob = router_client.get_job(job_identifier_2) + + assignment_id_for_job_1 = ( + accept_job_offer_result_1.assignment_id + if accept_job_offer_result_1.job_id == job_identifier_1 + else accept_job_offer_result_2.assignment_id + ) + assignment_id_for_job_2 = ( + accept_job_offer_result_1.assignment_id + if accept_job_offer_result_1.job_id == job_identifier_2 + else accept_job_offer_result_2.assignment_id + ) + + job_assignment_1: RouterJobAssignment = queried_job_1.assignments[assignment_id_for_job_1] + assert job_assignment_1.assigned_at is not None + assert job_assignment_1.worker_id == self.get_router_worker_id() + assert job_assignment_1.completed_at is not None + assert job_assignment_1.closed_at is not None + + job_assignment_2: RouterJobAssignment = queried_job_2.assignments[assignment_id_for_job_2] + assert job_assignment_2.assigned_at is not None + assert job_assignment_2.worker_id == self.get_router_worker_id() + assert job_assignment_2.completed_at is not None + assert job_assignment_2.closed_at is not None diff --git a/sdk/communication/azure-communication-jobrouter/tests/test_limit_concurrent_offer_worker_scenario_async.py b/sdk/communication/azure-communication-jobrouter/tests/test_limit_concurrent_offer_worker_scenario_async.py new file mode 100644 index 000000000000..cc050fb6f283 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/tests/test_limit_concurrent_offer_worker_scenario_async.py @@ -0,0 +1,304 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from datetime import datetime +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from azure.core.exceptions import ( + HttpResponseError, +) +from _router_test_case_async import AsyncRouterRecordedTestCase + +from _decorators_async import RouterPreparersAsync +from azure.communication.jobrouter._shared.utils import parse_connection_str + +from azure.communication.jobrouter.aio import ( + JobRouterAdministrationClient, + JobRouterClient, +) +from azure.communication.jobrouter.models import ( + LongestIdleMode, + RouterChannel, + RouterJobStatus, + RouterWorker, + RouterJobOffer, + AcceptJobOfferResult, + UnassignJobResult, + RouterJob, + RouterJobAssignment, + RouterWorkerState, + DistributionPolicy, + RouterQueue, + CancelJobOptions, + CompleteJobOptions, + CloseJobOptions, + DeclineJobOfferOptions, +) + + +channel_id = "fakeChannel2_async" + + +# The test class name needs to start with "Test" to get collected by pytest +class TestLimitConcurrentOffersToWorkerScenarioAsync(AsyncRouterRecordedTestCase): + async def clean_up(self, **kwargs): + # delete in live mode + if not self.is_playback(): + router_admin_client: JobRouterAdministrationClient = self.create_admin_client() + router_client: JobRouterClient = self.create_client() + + async with router_client: + async with router_admin_client: + if self._testMethodName in self.job_ids and any(self.job_ids[self._testMethodName]): + for _id in set(self.job_ids[self._testMethodName]): + await self.clean_up_job(job_id=_id, suppress_errors=True) + + if self._testMethodName in self.worker_ids and any(self.worker_ids[self._testMethodName]): + for _id in set(self.worker_ids[self._testMethodName]): + # delete worker + await router_client.delete_worker(_id) + + if self._testMethodName in self.classification_policy_ids and any( + self.classification_policy_ids[self._testMethodName] + ): + for policy_id in set(self.classification_policy_ids[self._testMethodName]): + await router_admin_client.delete_classification_policy(policy_id) + + if self._testMethodName in self.queue_ids and any(self.queue_ids[self._testMethodName]): + for policy_id in set(self.queue_ids[self._testMethodName]): + await router_admin_client.delete_queue(policy_id) + + if self._testMethodName in self.distribution_policy_ids and any( + self.distribution_policy_ids[self._testMethodName] + ): + for policy_id in set(self.distribution_policy_ids[self._testMethodName]): + await router_admin_client.delete_distribution_policy(policy_id) + + def get_distribution_policy_id(self, **kwargs): + return self._testMethodName + "_tst_dp_async" + + async def setup_distribution_policy(self, **kwargs): + client: JobRouterAdministrationClient = self.create_admin_client() + + async with client: + distribution_policy_id = self.get_distribution_policy_id() + + policy: DistributionPolicy = DistributionPolicy( + name="test", + offer_expires_after_seconds=10.0 * 60, + mode=LongestIdleMode(min_concurrent_offers=1, max_concurrent_offers=1), + ) + + distribution_policy = await client.upsert_distribution_policy(distribution_policy_id, policy) + + # add for cleanup later + if self._testMethodName in self.distribution_policy_ids: + self.distribution_policy_ids[self._testMethodName] = self.distribution_policy_ids[ + self._testMethodName + ].append(distribution_policy_id) + else: + self.distribution_policy_ids[self._testMethodName] = [distribution_policy_id] + + def get_job_queue_id(self, **kwargs): + return self._testMethodName + "_tst_q_async" + + async def setup_job_queue(self, **kwargs): + client: JobRouterAdministrationClient = self.create_admin_client() + + async with client: + job_queue_id = self.get_job_queue_id() + + job_queue: RouterQueue = RouterQueue(name="test", distribution_policy_id=self.get_distribution_policy_id()) + + job_queue = await client.upsert_queue(job_queue_id, job_queue) + + # add for cleanup later + if self._testMethodName in self.queue_ids: + self.queue_ids[self._testMethodName] = self.queue_ids[self._testMethodName].append(job_queue_id) + else: + self.queue_ids[self._testMethodName] = [job_queue_id] + + def get_router_worker_id(self, **kwargs): + return self._testMethodName + "_tst_w_async" + + async def setup_router_worker(self, **kwargs): + w_identifier = self.get_router_worker_id() + router_client: JobRouterClient = self.create_client() + + async with router_client: + worker_queues = [self.get_job_queue_id()] + worker_channels = [RouterChannel(channel_id=channel_id, capacity_cost_per_job=1)] + + worker: RouterWorker = RouterWorker( + capacity=10, + queues=worker_queues, + channels=worker_channels, + available_for_offers=True, + max_concurrent_offers=1, + ) + + router_worker = await router_client.upsert_worker(w_identifier, worker) + + # add for cleanup + self.worker_ids[self._testMethodName] = [w_identifier] + + async def validate_job_is_queued(self, identifier, **kwargs): + router_client: JobRouterClient = self.create_client() + + async with router_client: + router_job = await router_client.get_job(identifier) + assert router_job.status == RouterJobStatus.QUEUED + + async def validate_worker_has_offer( + self, + worker_id, # type: str + job_ids, # type: List[str] + **kwargs, # type: Any + ): + router_client: JobRouterClient = self.create_client() + + async with router_client: + router_worker: RouterWorker = await router_client.get_worker(worker_id) + offer_for_jobs = [job_offer for job_offer in router_worker.offers if job_offer.job_id in job_ids] + assert any(offer_for_jobs) + + async def validate_worker_deregistration( # cSpell:disable-line + self, + worker_id, # type: str + **kwargs, # type: Any + ): + router_client: JobRouterClient = self.create_client() + + async with router_client: + router_worker: RouterWorker = await router_client.get_worker(worker_id) + assert router_worker.state == RouterWorkerState.INACTIVE + + @RouterPreparersAsync.router_test_decorator_async + @recorded_by_proxy_async + @RouterPreparersAsync.before_test_execute_async("setup_distribution_policy") + @RouterPreparersAsync.before_test_execute_async("setup_job_queue") + @RouterPreparersAsync.before_test_execute_async("setup_router_worker") + @RouterPreparersAsync.after_test_execute_async("clean_up") + async def test_limit_concurrent_offer_to_worker_scenario(self, **kwargs): + router_client: JobRouterClient = self.create_client() + + async with router_client: + # create job + job_identifier_1 = f"concurrent_offer_worker_scenario_job_id_1_async" + job_identifier_2 = f"concurrent_offer_worker_scenario_job_id_2_async" + job_ids = [job_identifier_1, job_identifier_2] + + router_job_1: RouterJob = RouterJob( + channel_id=channel_id, + queue_id=self.get_job_queue_id(), + priority=1, + ) + + router_job_1: RouterJob = await router_client.upsert_job(job_identifier_1, router_job_1) + + # add for cleanup + self.job_ids[self._testMethodName] = [job_identifier_1] + + assert router_job_1 is not None + + # validate there are offers made + await self._poll_until_no_exception( + self.validate_worker_has_offer, AssertionError, self.get_router_worker_id(), job_ids + ) + + router_job_2: RouterJob = RouterJob( + channel_id=channel_id, + queue_id=self.get_job_queue_id(), + priority=1, + ) + router_job_2: RouterJob = await router_client.upsert_job(job_identifier_2, router_job_2) + + # add for cleanup + self.job_ids[self._testMethodName].append(job_identifier_2) + + # validate there are still offers + await self._poll_until_no_exception( + self.validate_worker_has_offer, AssertionError, self.get_router_worker_id(), job_ids + ) + + router_worker = await router_client.get_worker(self.get_router_worker_id()) + job_offers = [job_offer for job_offer in router_worker.offers if job_offer.job_id in job_ids] + + assert len(job_offers) == 1 + job_offer_1: RouterJobOffer = job_offers[0] + assert job_offer_1.capacity_cost == 1 + assert job_offer_1.offered_at is not None + assert job_offer_1.expires_at is not None + job_without_offer: str = job_identifier_2 if job_offer_1.job_id == job_identifier_1 else job_identifier_1 + + # accept job offer + offer_id_1: str = job_offer_1.offer_id + accept_job_offer_result_1: AcceptJobOfferResult = await router_client.accept_job_offer( + worker_id=self.get_router_worker_id(), offer_id=offer_id_1 + ) + + assert accept_job_offer_result_1.job_id == job_offer_1.job_id + assert accept_job_offer_result_1.worker_id == self.get_router_worker_id() + + # check for new offers sent to worker now that previous offer has been accepted + await self._poll_until_no_exception( + self.validate_worker_has_offer, AssertionError, self.get_router_worker_id(), [job_without_offer] + ) + + router_worker = await router_client.get_worker(self.get_router_worker_id()) + job_offers = [job_offer for job_offer in router_worker.offers if job_offer.job_id == job_without_offer] + + assert len(job_offers) == 1 + job_offer_2: RouterJobOffer = job_offers[0] + assert job_offer_2.capacity_cost == 1 + assert job_offer_2.offered_at is not None + assert job_offer_2.expires_at is not None + + # accept job offer + offer_id_2 = job_offer_2.offer_id + accept_job_offer_result_2: AcceptJobOfferResult = await router_client.accept_job_offer( + worker_id=self.get_router_worker_id(), offer_id=offer_id_2 + ) + + assert accept_job_offer_result_2.job_id == job_without_offer + assert accept_job_offer_result_2.worker_id == self.get_router_worker_id() + + # complete both jobs + await router_client.complete_job(accept_job_offer_result_1.job_id, accept_job_offer_result_1.assignment_id) + await router_client.complete_job(accept_job_offer_result_2.job_id, accept_job_offer_result_2.assignment_id) + + # close both jobs + await router_client.close_job(accept_job_offer_result_1.job_id, accept_job_offer_result_1.assignment_id) + await router_client.close_job(accept_job_offer_result_2.job_id, accept_job_offer_result_2.assignment_id) + + # validate post closure job details + queried_job_1: RouterJob = await router_client.get_job(job_identifier_1) + queried_job_2: RouterJob = await router_client.get_job(job_identifier_2) + + assignment_id_for_job_1 = ( + accept_job_offer_result_1.assignment_id + if accept_job_offer_result_1.job_id == job_identifier_1 + else accept_job_offer_result_2.assignment_id + ) + assignment_id_for_job_2 = ( + accept_job_offer_result_1.assignment_id + if accept_job_offer_result_1.job_id == job_identifier_2 + else accept_job_offer_result_2.assignment_id + ) + + job_assignment_1: RouterJobAssignment = queried_job_1.assignments[assignment_id_for_job_1] + assert job_assignment_1.assigned_at is not None + assert job_assignment_1.worker_id == self.get_router_worker_id() + assert job_assignment_1.completed_at is not None + assert job_assignment_1.closed_at is not None + + job_assignment_2: RouterJobAssignment = queried_job_2.assignments[assignment_id_for_job_2] + assert job_assignment_2.assigned_at is not None + assert job_assignment_2.worker_id == self.get_router_worker_id() + assert job_assignment_2.completed_at is not None + assert job_assignment_2.closed_at is not None diff --git a/sdk/communication/azure-communication-jobrouter/tsp-location.yaml b/sdk/communication/azure-communication-jobrouter/tsp-location.yaml index 142c21483fcd..81316b5b2ed6 100644 --- a/sdk/communication/azure-communication-jobrouter/tsp-location.yaml +++ b/sdk/communication/azure-communication-jobrouter/tsp-location.yaml @@ -1,5 +1,5 @@ repo: Azure/azure-rest-api-specs additionalDirectories: [] directory: specification/communication/Communication.JobRouter -commit: 2d044b8a317aff46d45080f5a797ac376955f648 +commit: 1c04f51cbfa195fe177239cf63d00d3539006800