From 0d88194df0489eabc9ab4bba7325c9dd502be48b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 15 Dec 2022 19:29:29 +0000 Subject: [PATCH] CodeGen from PR 21716 in Azure/azure-rest-api-specs Merge 284d7fdfe30979590d777b648a389428a48f4d93 into 038922fd638b28f04ad706a916b486f8392c7cef --- .../azure-mgmt-cognitiveservices/_meta.json | 8 +- .../azure/mgmt/cognitiveservices/__init__.py | 6 +- .../_cognitive_services_management_client.py | 15 +- .../mgmt/cognitiveservices/_configuration.py | 15 +- .../mgmt/cognitiveservices/_serialization.py | 93 +- .../azure/mgmt/cognitiveservices/_vendor.py | 2 +- .../azure/mgmt/cognitiveservices/_version.py | 2 +- .../mgmt/cognitiveservices/aio/__init__.py | 6 +- .../_cognitive_services_management_client.py | 6 +- .../cognitiveservices/aio/_configuration.py | 10 +- .../mgmt/cognitiveservices/aio/_vendor.py | 2 +- .../aio/operations/__init__.py | 2 +- .../aio/operations/_accounts_operations.py | 247 +- ...e_services_management_client_operations.py | 41 +- .../_commitment_plans_operations.py | 1488 +++++++++++- .../_commitment_tiers_operations.py | 25 +- .../_deleted_accounts_operations.py | 69 +- .../aio/operations/_deployments_operations.py | 113 +- .../aio/operations/_operations.py | 23 +- ...private_endpoint_connections_operations.py | 109 +- .../_private_link_resources_operations.py | 21 +- .../operations/_resource_skus_operations.py | 23 +- .../mgmt/cognitiveservices/models/__init__.py | 22 +- ...nitive_services_management_client_enums.py | 27 + .../cognitiveservices/models/_models_py3.py | 315 ++- .../cognitiveservices/operations/__init__.py | 2 +- .../operations/_accounts_operations.py | 297 ++- ...e_services_management_client_operations.py | 53 +- .../_commitment_plans_operations.py | 2117 +++++++++++++++-- .../_commitment_tiers_operations.py | 29 +- .../_deleted_accounts_operations.py | 81 +- .../operations/_deployments_operations.py | 131 +- .../operations/_operations.py | 25 +- ...private_endpoint_connections_operations.py | 127 +- .../_private_link_resources_operations.py | 25 +- .../operations/_resource_skus_operations.py | 27 +- .../generated_samples/create_account.py | 62 + .../generated_samples/create_account_min.py | 48 + .../create_shared_commitment_plan.py | 47 + ...eate_shared_commitment_plan_association.py | 47 + .../generated_samples/delete_account.py | 41 + .../delete_commitment_plan.py | 42 + .../generated_samples/delete_deployment.py | 42 + .../delete_private_endpoint_connection.py | 42 + .../delete_shared_commitment_plan.py | 41 + ...lete_shared_commitment_plan_association.py | 42 + .../generated_samples/get_account.py | 41 + .../generated_samples/get_commitment_plan.py | 42 + .../generated_samples/get_deleted_account.py | 42 + .../generated_samples/get_deployment.py | 42 + .../generated_samples/get_operations.py | 39 + .../get_private_endpoint_connection.py | 42 + .../get_shared_commitment_plan.py | 41 + .../get_shared_commitment_plan_association.py | 42 + .../generated_samples/get_skus.py | 39 + .../generated_samples/get_usages.py | 41 + .../generated_samples/list_account_models.py | 42 + .../list_accounts_by_resource_group.py | 41 + .../list_accounts_by_subscription.py | 39 + .../list_commitment_plans.py | 42 + .../list_commitment_tiers.py | 41 + .../list_deleted_accounts_by_subscription.py | 39 + .../generated_samples/list_deployments.py | 42 + .../generated_samples/list_keys.py | 41 + .../list_private_endpoint_connections.py | 41 + .../list_private_link_resources.py | 41 + ...ist_shared_commitment_plan_associations.py | 42 + ...ared_commitment_plans_by_resource_group.py | 41 + ...shared_commitment_plans_by_subscription.py | 39 + .../generated_samples/list_skus.py | 41 + .../purge_deleted_account.py | 42 + .../generated_samples/put_commitment_plan.py | 50 + .../generated_samples/put_deployment.py | 48 + .../put_private_endpoint_connection.py | 45 + .../generated_samples/update_account.py | 42 + .../update_shared_commitment_plan.py | 42 + 76 files changed, 6470 insertions(+), 840 deletions(-) create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account_min.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan_association.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_account.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_commitment_plan.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_deployment.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_private_endpoint_connection.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan_association.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_account.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_commitment_plan.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deleted_account.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deployment.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_operations.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_private_endpoint_connection.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan_association.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_skus.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_usages.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_account_models.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_resource_group.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_subscription.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_plans.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_tiers.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deleted_accounts_by_subscription.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deployments.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_keys.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_endpoint_connections.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_link_resources.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plan_associations.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_resource_group.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_subscription.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_skus.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/purge_deleted_account.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_commitment_plan.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_deployment.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_private_endpoint_connection.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_account.py create mode 100644 sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_shared_commitment_plan.py diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json index 8e03ef471ef7..b742dcf68f92 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json @@ -1,11 +1,11 @@ { + "commit": "8835b30846e95518c5b8e7c276ffc94fd13fe567", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.1.11", + "@autorest/python@6.2.7", "@autorest/modelerfour@4.24.3" ], - "commit": "f3312d0962e91b065f287e44f5ae76db038fcd87", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.1.11 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/cognitiveservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py index 04e27dd384dd..534cb95c3a3f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["CognitiveServicesManagementClient"] +__all__ = [ + "CognitiveServicesManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py index 378ec39b5784..365db16da68e 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from ._configuration import CognitiveServicesManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( @@ -64,7 +64,7 @@ class CognitiveServicesManagementClient( :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -83,7 +83,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -129,15 +129,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> CognitiveServicesManagementClient + def __enter__(self) -> "CognitiveServicesManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py index 8c0f68ffe82f..be134fffb0a9 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 azure.core.credentials import TokenCredential @@ -29,14 +35,14 @@ class CognitiveServicesManagementClientConfiguration(Configuration): # pylint: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-10-01") # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", "2022-12-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-cognitiveservices/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_serialization.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_serialization.py index 7c1dedb5133d..2c170e28dbca 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_serialization.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_serialization.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- # pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode import calendar @@ -37,24 +38,22 @@ import re import sys import codecs +from typing import Optional, Union, AnyStr, IO, Mapping try: from urllib import quote # type: ignore except ImportError: - from urllib.parse import quote # type: ignore + from urllib.parse import quote import xml.etree.ElementTree as ET -import isodate +import isodate # type: ignore -from typing import Dict, Any, cast, TYPE_CHECKING +from typing import Dict, Any, cast from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -if TYPE_CHECKING: - from typing import Optional, Union, AnyStr, IO, Mapping - class RawDeserializer: @@ -65,8 +64,7 @@ class RawDeserializer: CONTEXT_NAME = "deserialized_data" @classmethod - def deserialize_from_text(cls, data, content_type=None): - # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: """Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. @@ -132,8 +130,7 @@ def _json_attemp(data): raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod - def deserialize_from_http_generics(cls, body_bytes, headers): - # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: """Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever @@ -160,8 +157,8 @@ def deserialize_from_http_generics(cls, body_bytes, headers): basestring # type: ignore unicode_str = unicode # type: ignore except NameError: - basestring = str # type: ignore - unicode_str = str # type: ignore + basestring = str + unicode_str = str _LOGGER = logging.getLogger(__name__) @@ -188,7 +185,7 @@ def dst(self, dt): try: - from datetime import timezone as _FixedOffset + from datetime import timezone as _FixedOffset # type: ignore except ImportError: # Python 2.7 class _FixedOffset(datetime.tzinfo): # type: ignore @@ -219,7 +216,7 @@ def __getinitargs__(self): try: from datetime import timezone - TZ_UTC = timezone.utc # type: ignore + TZ_UTC = timezone.utc except ImportError: TZ_UTC = UTC() # type: ignore @@ -276,9 +273,9 @@ class Model(object): serialization and deserialization. """ - _subtype_map = {} # type: Dict[str, Dict[str, Any]] - _attribute_map = {} # type: Dict[str, Dict[str, Any]] - _validation = {} # type: Dict[str, Dict[str, Any]] + _subtype_map: Dict[str, Dict[str, Any]] = {} + _attribute_map: Dict[str, Dict[str, Any]] = {} + _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs): self.additional_properties = {} @@ -310,7 +307,7 @@ def enable_additional_properties_sending(cls): @classmethod def is_xml_model(cls): try: - cls._xml_map + cls._xml_map # type: ignore except AttributeError: return False return True @@ -319,7 +316,7 @@ def is_xml_model(cls): def _create_xml_node(cls): """Create XML node.""" try: - xml_map = cls._xml_map + xml_map = cls._xml_map # type: ignore except AttributeError: xml_map = {} @@ -453,7 +450,7 @@ def _classify(cls, response, objects): return cls flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) try: - return objects[flatten_mapping_type[subtype_value]] + return objects[flatten_mapping_type[subtype_value]] # type: ignore except KeyError: _LOGGER.warning( "Subtype value %s has no mapping, use base class %s.", @@ -606,13 +603,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) xml_name = "{}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) + serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): - serialized.text = new_attr + serialized.text = new_attr # type: ignore continue if isinstance(new_attr, list): - serialized.extend(new_attr) + serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): @@ -621,23 +618,23 @@ def _serialize(self, target_obj, data_type=None, **kwargs): new_attr.tag = "}".join([splitted_tag[0], xml_name]) else: new_attr.tag = xml_name - serialized.append(new_attr) + serialized.append(new_attr) # type: ignore 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) - serialized.append(local_node) + serialized.append(local_node) # type: ignore else: # JSON - for k in reversed(keys): + for k in reversed(keys): # type: ignore unflattened = {k: new_attr} new_attr = unflattened _new_attr = new_attr _serialized = serialized - for k in keys: + for k in keys: # type: ignore if k not in _serialized: - _serialized.update(_new_attr) - _new_attr = _new_attr[k] + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] except ValueError: continue @@ -675,7 +672,7 @@ def body(self, data, data_type, **kwargs): # We're not able to deal with additional properties for now. deserializer.additional_properties_detection = False if is_xml_model_serialization: - deserializer.key_extractors = [ + deserializer.key_extractors = [ # type: ignore attribute_key_case_insensitive_extractor, ] else: @@ -843,7 +840,7 @@ def serialize_unicode(cls, data): pass try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore # Don't change it, JSON and XML ElementTree are totally able # to serialize correctly u'' strings return data @@ -1001,10 +998,10 @@ def serialize_enum(attr, enum_obj=None): except AttributeError: result = attr try: - enum_obj(result) + enum_obj(result) # type: ignore return result except ValueError: - for enum_value in enum_obj: + for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" @@ -1416,7 +1413,7 @@ def _deserialize(self, target_obj, data): if data is None: return data try: - attributes = response._attribute_map + attributes = response._attribute_map # type: ignore d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1444,7 +1441,7 @@ def _deserialize(self, target_obj, data): value = self.deserialize_data(raw_value, attr_desc["type"]) d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name + msg = "Unable to deserialize to object: " + class_name # type: ignore raise_with_traceback(DeserializationError, msg, err) else: additional_properties = self._build_additional_properties(attributes, data) @@ -1543,7 +1540,7 @@ def _unpack_content(raw_data, content_type=None): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): @@ -1565,7 +1562,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): response_obj.additional_properties = additional_properties return response_obj except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore raise DeserializationError(msg + str(err)) else: try: @@ -1747,7 +1744,7 @@ def deserialize_unicode(data): # Consider this is real string try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore return data except NameError: return str(data) @@ -1798,7 +1795,7 @@ def deserialize_bytearray(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return bytearray(b64decode(attr)) + return bytearray(b64decode(attr)) # type: ignore @staticmethod def deserialize_base64(attr): @@ -1810,8 +1807,8 @@ def deserialize_base64(attr): """ if isinstance(attr, ET.Element): attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) - attr = attr + padding + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore encoded = attr.replace("-", "+").replace("_", "/") return b64decode(encoded) @@ -1826,7 +1823,7 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) + return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) raise_with_traceback(DeserializationError, msg, err) @@ -1841,7 +1838,7 @@ def deserialize_long(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return _long_type(attr) + return _long_type(attr) # type: ignore @staticmethod def deserialize_duration(attr): @@ -1871,7 +1868,7 @@ def deserialize_date(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. return isodate.parse_date(attr, defaultmonth=None, defaultday=None) @@ -1886,7 +1883,7 @@ def deserialize_time(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) return isodate.parse_time(attr) @@ -1901,7 +1898,7 @@ def deserialize_rfc(attr): if isinstance(attr, ET.Element): attr = attr.text try: - parsed_date = email.utils.parsedate_tz(attr) + parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) @@ -1924,7 +1921,7 @@ def deserialize_iso(attr): if isinstance(attr, ET.Element): attr = attr.text try: - attr = attr.upper() + attr = attr.upper() # type: ignore match = Deserializer.valid_date.match(attr) if not match: raise ValueError("Invalid datetime string: " + attr) @@ -1960,7 +1957,7 @@ def deserialize_unix(attr): :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): - attr = int(attr.text) + attr = int(attr.text) # type: ignore try: date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py index 70850649060a..736da5bc66a5 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py @@ -38,7 +38,7 @@ def _format_url_section(template, **kwargs): template = "/".join(components) -class MixinABC(ABC): +class CognitiveServicesManagementClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" _client: "PipelineClient" diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py index d0255959d2e5..75a1436b862f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.3.0" +VERSION = "11.0.0b1" diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py index 991367a79038..2e952442ec90 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["CognitiveServicesManagementClient"] +__all__ = [ + "CognitiveServicesManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py index fd983dfb85a4..7035d5ba8614 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import CognitiveServicesManagementClientConfiguration from .operations import ( @@ -67,7 +67,7 @@ class CognitiveServicesManagementClient( :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -86,7 +86,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py index 871b8db0e81c..59bf3cad40ed 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 azure.core.credentials_async import AsyncTokenCredential @@ -29,14 +35,14 @@ class CognitiveServicesManagementClientConfiguration(Configuration): # pylint: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-10-01") # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", "2022-12-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_vendor.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_vendor.py index 803df16c0c1f..ae033a9e6c69 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_vendor.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_vendor.py @@ -19,7 +19,7 @@ from .._serialization import Deserializer, Serializer -class MixinABC(ABC): +class CognitiveServicesManagementClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" _client: "AsyncPipelineClient" diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py index 110082e7aa36..2a93c77cfb1e 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py @@ -18,7 +18,7 @@ from ._commitment_plans_operations import CommitmentPlansOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py index 697d3ce24913..c8c30606c174 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -43,8 +44,12 @@ build_regenerate_key_request, build_update_request, ) -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,9 +87,11 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -107,9 +114,9 @@ async def _create_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -130,11 +137,13 @@ async def _create_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @overload async def begin_create( @@ -244,14 +253,16 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_initial( # type: ignore + raw_result = await self._create_initial( resource_group_name=resource_group_name, account_name=account_name, account=account, @@ -271,7 +282,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -283,9 +294,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } async def _update_initial( self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO], **kwargs: Any @@ -301,9 +314,11 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -326,9 +341,9 @@ async def _update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -346,11 +361,13 @@ async def _update_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @overload async def begin_update( @@ -457,14 +474,16 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, account_name=account_name, account=account, @@ -484,7 +503,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -496,9 +515,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any @@ -514,8 +535,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -527,9 +550,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +566,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @distributed_trace_async async def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -569,11 +594,13 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -591,7 +618,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -603,9 +630,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: @@ -632,8 +661,10 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -645,9 +676,9 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -665,7 +696,9 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Account"]: @@ -682,8 +715,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -705,7 +740,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -721,7 +756,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -729,13 +764,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -749,7 +784,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Account"]: @@ -763,8 +800,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Account"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -785,7 +824,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -801,7 +840,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -809,13 +848,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -829,7 +868,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts"} @distributed_trace_async async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ApiKeys: @@ -856,8 +895,10 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiKeys] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) request = build_list_keys_request( resource_group_name=resource_group_name, @@ -869,9 +910,9 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -889,7 +930,9 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: return deserialized - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys" + } @distributed_trace_async async def regenerate_key( @@ -921,9 +964,11 @@ async def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiKeys] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) _parameters = _models.RegenerateKeyParameters(key_name=key_name) _json = self._serialize.body(_parameters, "RegenerateKeyParameters") @@ -940,9 +985,9 @@ async def regenerate_key( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -960,7 +1005,9 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey" + } @distributed_trace_async async def list_skus( @@ -989,8 +1036,10 @@ async def list_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountSkuListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountSkuListResult] = kwargs.pop("cls", None) request = build_list_skus_request( resource_group_name=resource_group_name, @@ -1002,9 +1051,9 @@ async def list_skus( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1022,7 +1071,9 @@ async def list_skus( return deserialized - list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus"} # type: ignore + list_skus.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus" + } @distributed_trace_async async def list_usages( @@ -1055,8 +1106,10 @@ async def list_usages( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) request = build_list_usages_request( resource_group_name=resource_group_name, @@ -1069,9 +1122,9 @@ async def list_usages( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1089,7 +1142,9 @@ async def list_usages( return deserialized - list_usages.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages"} # type: ignore + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages" + } @distributed_trace def list_models( @@ -1111,8 +1166,10 @@ def list_models( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountModelListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountModelListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1135,7 +1192,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1151,7 +1208,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1159,13 +1216,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AccountModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1179,4 +1236,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_models.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models"} # type: ignore + list_models.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py index 04ae59764fb0..50e021391b1d 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ( @@ -29,13 +30,17 @@ build_check_domain_availability_request, build_check_sku_availability_request, ) -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CognitiveServicesManagementClientOperationsMixin(MixinABC): +class CognitiveServicesManagementClientOperationsMixin(CognitiveServicesManagementClientMixinABC): @distributed_trace_async async def check_sku_availability( self, location: str, skus: List[str], kind: str, type: str, **kwargs: Any @@ -66,9 +71,11 @@ async def check_sku_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuAvailabilityListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.SkuAvailabilityListResult] = kwargs.pop("cls", None) _parameters = _models.CheckSkuAvailabilityParameter(kind=kind, skus=skus, type=type) _json = self._serialize.body(_parameters, "CheckSkuAvailabilityParameter") @@ -84,9 +91,9 @@ async def check_sku_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -104,7 +111,9 @@ async def check_sku_availability( return deserialized - check_sku_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability"} # type: ignore + check_sku_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability" + } @distributed_trace_async async def check_domain_availability( @@ -134,9 +143,11 @@ async def check_domain_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainAvailability] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.DomainAvailability] = kwargs.pop("cls", None) _parameters = _models.CheckDomainAvailabilityParameter(kind=kind, subdomain_name=subdomain_name, type=type) _json = self._serialize.body(_parameters, "CheckDomainAvailabilityParameter") @@ -151,9 +162,9 @@ async def check_domain_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -171,4 +182,6 @@ async def check_domain_availability( return deserialized - check_domain_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability"} # type: ignore + check_domain_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py index 4a4ff3d30925..dbac14075097 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -31,13 +32,27 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._commitment_plans_operations import ( + build_create_or_update_association_request, + build_create_or_update_plan_request, build_create_or_update_request, + build_delete_association_request, + build_delete_plan_request, build_delete_request, + build_get_association_request, + build_get_plan_request, build_get_request, + build_list_associations_request, + build_list_plans_by_resource_group_request, + build_list_plans_by_subscription_request, build_list_request, + build_update_plan_request, ) -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +96,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentPlanListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -105,7 +122,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -121,7 +138,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -129,13 +146,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,7 +166,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans" + } @distributed_trace_async async def get( @@ -181,8 +200,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentPlan] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -195,9 +216,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -215,7 +236,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } @overload async def create_or_update( @@ -322,9 +345,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentPlan] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -348,9 +373,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -368,11 +393,13 @@ async def create_or_update( deserialized = self._deserialize("CommitmentPlan", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any @@ -388,8 +415,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -402,9 +431,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -418,7 +447,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } @distributed_trace_async async def begin_delete( @@ -449,11 +480,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -472,7 +505,1394 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } + + async def _create_or_update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, IO], + **kwargs: Any + ) -> _models.CommitmentPlan: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(commitment_plan, (IO, bytes)): + _content = commitment_plan + else: + _json = self._serialize.body(commitment_plan, "CommitmentPlan") + + request = build_create_or_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_plan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_plan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @overload + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is either a + model type or a IO type. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + async def _update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, IO], + **kwargs: Any + ) -> Optional[_models.CommitmentPlan]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(commitment_plan, (IO, bytes)): + _content = commitment_plan + else: + _json = self._serialize.body(commitment_plan, "PatchResourceTagsAndSku") + + request = build_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_plan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_plan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @overload + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.PatchResourceTagsAndSku, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is either a + model type or a IO type. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + async def _delete_plan_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_plan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_plan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace_async + async def begin_delete_plan( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Cognitive Services commitment plan from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_plan_initial( # type: ignore + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace_async + async def get_plan( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> _models.CommitmentPlan: + """Returns a Cognitive Services commitment plan specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlan or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + request = build_get_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_plan.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace + def list_plans_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommitmentPlan or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_plans_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_plans_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_plans_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans" + } + + @distributed_trace + def list_plans_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommitmentPlan or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_plans_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_plans_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_plans_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/commitmentPlans" + } + + @distributed_trace + def list_associations( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CommitmentPlanAccountAssociation"]: + """Gets the associations of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommitmentPlanAccountAssociation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanAccountAssociationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_associations_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_associations.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CommitmentPlanAccountAssociationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_associations.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations" + } + + @distributed_trace_async + async def get_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> _models.CommitmentPlanAccountAssociation: + """Gets the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlanAccountAssociation or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + + request = build_get_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_association.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_association.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } + + async def _create_or_update_association_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, IO], + **kwargs: Any + ) -> _models.CommitmentPlanAccountAssociation: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(association, (IO, bytes)): + _content = association + else: + _json = self._serialize.body(association, "CommitmentPlanAccountAssociation") + + request = build_create_or_update_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_association_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_association_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } + + @overload + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: _models.CommitmentPlanAccountAssociation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlanAccountAssociation or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlanAccountAssociation or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Is either a model type or a IO type. + Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommitmentPlanAccountAssociation or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_association_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + association=association, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_association.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } + + async def _delete_association_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_association_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_association_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } + + @distributed_trace_async + async def begin_delete_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_association_initial( # type: ignore + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -484,6 +1904,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + begin_delete_association.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py index 17ffd615bf44..004312795a67 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -28,8 +29,12 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._commitment_tiers_operations import build_list_request -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,8 +73,10 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Commitmen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentTierListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentTierListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -91,7 +98,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -107,7 +114,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -115,13 +122,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("CommitmentTierListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -135,4 +142,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/commitmentTiers"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/commitmentTiers" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py index 23b840cb37c7..95b50fb9fa45 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast import urllib.parse @@ -31,8 +32,12 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request, build_purge_request -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,8 +88,10 @@ async def get(self, location: str, resource_group_name: str, account_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) request = build_get_request( location=location, @@ -97,9 +104,9 @@ async def get(self, location: str, resource_group_name: str, account_name: str, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -117,7 +124,9 @@ async def get(self, location: str, resource_group_name: str, account_name: str, return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + } async def _purge_initial( # pylint: disable=inconsistent-return-statements self, location: str, resource_group_name: str, account_name: str, **kwargs: Any @@ -133,8 +142,10 @@ async def _purge_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_purge_request( location=location, @@ -147,9 +158,9 @@ async def _purge_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -163,7 +174,9 @@ async def _purge_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _purge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}"} # type: ignore + _purge_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + } @distributed_trace_async async def begin_purge( @@ -193,11 +206,13 @@ async def begin_purge( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._purge_initial( # type: ignore location=location, @@ -216,7 +231,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -228,9 +243,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_purge.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}"} # type: ignore + begin_purge.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Account"]: @@ -244,8 +261,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Account"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -266,7 +285,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -282,7 +301,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -290,13 +309,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -310,4 +329,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/deletedAccounts"} diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py index d2a12f261fdb..18a18bc30286 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -36,8 +37,12 @@ build_get_request, build_list_request, ) -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,8 +84,10 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.DeploymentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -103,7 +110,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -119,7 +126,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -127,13 +134,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,7 +154,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments" + } @distributed_trace_async async def get( @@ -179,8 +188,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Deployment] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -193,9 +204,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -213,7 +224,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } async def _create_or_update_initial( self, @@ -234,9 +247,11 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Deployment] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -260,9 +275,9 @@ async def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -280,11 +295,13 @@ async def _create_or_update_initial( deserialized = self._deserialize("Deployment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } @overload async def begin_create_or_update( @@ -406,14 +423,16 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Deployment] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, deployment_name=deployment_name, @@ -434,7 +453,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -446,9 +465,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any @@ -464,8 +485,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -478,9 +501,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -494,7 +517,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } @distributed_trace_async async def begin_delete( @@ -525,11 +550,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -548,7 +575,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -560,6 +587,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py index 4748a922bcf6..a6a3c2ddab84 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -28,8 +29,12 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,8 +70,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -86,7 +93,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -102,7 +109,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -110,13 +117,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,4 +137,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.CognitiveServices/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.CognitiveServices/operations"} diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py index f1303530fca7..ac9e511cd5ff 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -33,8 +34,12 @@ build_get_request, build_list_request, ) -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,8 +90,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) request = build_list_request( resource_group_name=resource_group_name, @@ -98,9 +105,9 @@ async def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -118,7 +125,9 @@ async def list( return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections" + } @distributed_trace_async async def get( @@ -150,8 +159,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -164,9 +175,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -184,7 +195,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, @@ -205,9 +218,11 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -231,9 +246,9 @@ async def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -251,11 +266,13 @@ async def _create_or_update_initial( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @overload async def begin_create_or_update( @@ -384,14 +401,16 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -412,7 +431,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -424,9 +443,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -442,8 +463,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -456,9 +479,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -472,7 +495,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async async def begin_delete( @@ -504,11 +529,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -527,7 +554,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -539,6 +566,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py index 01e695219bad..4e437dcc9cff 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,8 +27,12 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_request -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,8 +83,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) request = build_list_request( resource_group_name=resource_group_name, @@ -91,9 +98,9 @@ async def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -111,4 +118,6 @@ async def list( return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py index 3f5640920f53..c13abc1e2a64 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -28,8 +29,12 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_skus_operations import build_list_request -from .._vendor import MixinABC +from .._vendor import CognitiveServicesManagementClientMixinABC +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,8 +71,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceSku"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ResourceSkuListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -88,7 +95,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -104,7 +111,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -112,13 +119,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,4 +139,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus"} diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py index e7a9228377ec..4d479e33642c 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py @@ -22,6 +22,9 @@ from ._models_py3 import CommitmentCost from ._models_py3 import CommitmentPeriod from ._models_py3 import CommitmentPlan +from ._models_py3 import CommitmentPlanAccountAssociation +from ._models_py3 import CommitmentPlanAccountAssociationListResult +from ._models_py3 import CommitmentPlanAssociation from ._models_py3 import CommitmentPlanListResult from ._models_py3 import CommitmentPlanProperties from ._models_py3 import CommitmentQuota @@ -42,10 +45,13 @@ from ._models_py3 import KeyVaultProperties from ._models_py3 import MetricName from ._models_py3 import ModelDeprecationInfo +from ._models_py3 import MultiRegionSettings from ._models_py3 import NetworkRuleSet from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import PatchResourceTags +from ._models_py3 import PatchResourceTagsAndSku from ._models_py3 import PrivateEndpoint from ._models_py3 import PrivateEndpointConnection from ._models_py3 import PrivateEndpointConnectionListResult @@ -57,6 +63,7 @@ from ._models_py3 import ProxyResource from ._models_py3 import QuotaLimit from ._models_py3 import RegenerateKeyParameters +from ._models_py3 import RegionSetting from ._models_py3 import RequestMatchPattern from ._models_py3 import Resource from ._models_py3 import ResourceSku @@ -77,12 +84,14 @@ from ._models_py3 import VirtualNetworkRule from ._cognitive_services_management_client_enums import ActionType +from ._cognitive_services_management_client_enums import CommitmentPlanProvisioningState from ._cognitive_services_management_client_enums import CreatedByType from ._cognitive_services_management_client_enums import DeploymentProvisioningState from ._cognitive_services_management_client_enums import DeploymentScaleType from ._cognitive_services_management_client_enums import HostingModel from ._cognitive_services_management_client_enums import KeyName from ._cognitive_services_management_client_enums import KeySource +from ._cognitive_services_management_client_enums import ModelLifecycleStatus from ._cognitive_services_management_client_enums import NetworkRuleAction from ._cognitive_services_management_client_enums import Origin from ._cognitive_services_management_client_enums import PrivateEndpointConnectionProvisioningState @@ -93,10 +102,11 @@ from ._cognitive_services_management_client_enums import ResourceIdentityType from ._cognitive_services_management_client_enums import ResourceSkuRestrictionsReasonCode from ._cognitive_services_management_client_enums import ResourceSkuRestrictionsType +from ._cognitive_services_management_client_enums import RoutingMethods from ._cognitive_services_management_client_enums import SkuTier from ._cognitive_services_management_client_enums import UnitType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -116,6 +126,9 @@ "CommitmentCost", "CommitmentPeriod", "CommitmentPlan", + "CommitmentPlanAccountAssociation", + "CommitmentPlanAccountAssociationListResult", + "CommitmentPlanAssociation", "CommitmentPlanListResult", "CommitmentPlanProperties", "CommitmentQuota", @@ -136,10 +149,13 @@ "KeyVaultProperties", "MetricName", "ModelDeprecationInfo", + "MultiRegionSettings", "NetworkRuleSet", "Operation", "OperationDisplay", "OperationListResult", + "PatchResourceTags", + "PatchResourceTagsAndSku", "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", @@ -151,6 +167,7 @@ "ProxyResource", "QuotaLimit", "RegenerateKeyParameters", + "RegionSetting", "RequestMatchPattern", "Resource", "ResourceSku", @@ -170,12 +187,14 @@ "UserOwnedStorage", "VirtualNetworkRule", "ActionType", + "CommitmentPlanProvisioningState", "CreatedByType", "DeploymentProvisioningState", "DeploymentScaleType", "HostingModel", "KeyName", "KeySource", + "ModelLifecycleStatus", "NetworkRuleAction", "Origin", "PrivateEndpointConnectionProvisioningState", @@ -186,6 +205,7 @@ "ResourceIdentityType", "ResourceSkuRestrictionsReasonCode", "ResourceSkuRestrictionsType", + "RoutingMethods", "SkuTier", "UnitType", ] diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py index ad98fe63fb65..fbe9732f0f7f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py @@ -16,6 +16,18 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class CommitmentPlanProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the resource at the time the operation was called.""" + + ACCEPTED = "Accepted" + CREATING = "Creating" + DELETING = "Deleting" + MOVING = "Moving" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -65,6 +77,13 @@ class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" +class ModelLifecycleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Model lifecycle status.""" + + GENERALLY_AVAILABLE = "GenerallyAvailable" + PREVIEW = "Preview" + + class NetworkRuleAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The default action when no rule from ipRules and from virtualNetworkRules match. This is only used after the bypass property has been evaluated. @@ -152,6 +171,14 @@ class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): ZONE = "Zone" +class RoutingMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Multiregion routing methods.""" + + PRIORITY = "Priority" + WEIGHTED = "Weighted" + PERFORMANCE = "Performance" + + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py index 50fd6abd52d5..9bc1504e294e 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py @@ -13,13 +13,14 @@ from .. import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -257,7 +258,7 @@ def __init__( self.call_rate_limit = None -class AccountModel(DeploymentModel): +class AccountModel(DeploymentModel): # pylint: disable=too-many-instance-attributes """Cognitive Services account Model. Variables are only populated by the server, and will be ignored when sending a request. @@ -276,8 +277,13 @@ class AccountModel(DeploymentModel): :vartype max_capacity: int :ivar capabilities: The capabilities. :vartype capabilities: dict[str, str] + :ivar finetune_capabilities: The capabilities for finetune models. + :vartype finetune_capabilities: dict[str, str] :ivar deprecation: Cognitive Services account ModelDeprecationInfo. :vartype deprecation: ~azure.mgmt.cognitiveservices.models.ModelDeprecationInfo + :ivar lifecycle_status: Model lifecycle status. Known values are: "GenerallyAvailable" and + "Preview". + :vartype lifecycle_status: str or ~azure.mgmt.cognitiveservices.models.ModelLifecycleStatus :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData """ @@ -295,7 +301,9 @@ class AccountModel(DeploymentModel): "base_model": {"key": "baseModel", "type": "DeploymentModel"}, "max_capacity": {"key": "maxCapacity", "type": "int"}, "capabilities": {"key": "capabilities", "type": "{str}"}, + "finetune_capabilities": {"key": "finetuneCapabilities", "type": "{str}"}, "deprecation": {"key": "deprecation", "type": "ModelDeprecationInfo"}, + "lifecycle_status": {"key": "lifecycleStatus", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, } @@ -308,7 +316,9 @@ def __init__( base_model: Optional["_models.DeploymentModel"] = None, max_capacity: Optional[int] = None, capabilities: Optional[Dict[str, str]] = None, + finetune_capabilities: Optional[Dict[str, str]] = None, deprecation: Optional["_models.ModelDeprecationInfo"] = None, + lifecycle_status: Optional[Union[str, "_models.ModelLifecycleStatus"]] = None, **kwargs ): """ @@ -324,14 +334,21 @@ def __init__( :paramtype max_capacity: int :keyword capabilities: The capabilities. :paramtype capabilities: dict[str, str] + :keyword finetune_capabilities: The capabilities for finetune models. + :paramtype finetune_capabilities: dict[str, str] :keyword deprecation: Cognitive Services account ModelDeprecationInfo. :paramtype deprecation: ~azure.mgmt.cognitiveservices.models.ModelDeprecationInfo + :keyword lifecycle_status: Model lifecycle status. Known values are: "GenerallyAvailable" and + "Preview". + :paramtype lifecycle_status: str or ~azure.mgmt.cognitiveservices.models.ModelLifecycleStatus """ super().__init__(format=format, name=name, version=version, **kwargs) self.base_model = base_model self.max_capacity = max_capacity self.capabilities = capabilities + self.finetune_capabilities = finetune_capabilities self.deprecation = deprecation + self.lifecycle_status = lifecycle_status self.system_data = None @@ -426,6 +443,12 @@ class AccountProperties(_serialization.Model): # pylint: disable=too-many-insta :vartype deletion_date: str :ivar scheduled_purge_date: The scheduled purge date, only available for deleted account. :vartype scheduled_purge_date: str + :ivar locations: The multiregion settings of Cognitive Services account. + :vartype locations: ~azure.mgmt.cognitiveservices.models.MultiRegionSettings + :ivar commitment_plan_associations: The commitment plan associations of Cognitive Services + account. + :vartype commitment_plan_associations: + list[~azure.mgmt.cognitiveservices.models.CommitmentPlanAssociation] """ _validation = { @@ -442,6 +465,7 @@ class AccountProperties(_serialization.Model): # pylint: disable=too-many-insta "endpoints": {"readonly": True}, "deletion_date": {"readonly": True}, "scheduled_purge_date": {"readonly": True}, + "commitment_plan_associations": {"readonly": True}, } _attribute_map = { @@ -470,6 +494,8 @@ class AccountProperties(_serialization.Model): # pylint: disable=too-many-insta "restore": {"key": "restore", "type": "bool"}, "deletion_date": {"key": "deletionDate", "type": "str"}, "scheduled_purge_date": {"key": "scheduledPurgeDate", "type": "str"}, + "locations": {"key": "locations", "type": "MultiRegionSettings"}, + "commitment_plan_associations": {"key": "commitmentPlanAssociations", "type": "[CommitmentPlanAssociation]"}, } def __init__( # pylint: disable=too-many-locals @@ -487,6 +513,7 @@ def __init__( # pylint: disable=too-many-locals allowed_fqdn_list: Optional[List[str]] = None, disable_local_auth: Optional[bool] = None, restore: Optional[bool] = None, + locations: Optional["_models.MultiRegionSettings"] = None, **kwargs ): """ @@ -517,6 +544,8 @@ def __init__( # pylint: disable=too-many-locals :paramtype disable_local_auth: bool :keyword restore: :paramtype restore: bool + :keyword locations: The multiregion settings of Cognitive Services account. + :paramtype locations: ~azure.mgmt.cognitiveservices.models.MultiRegionSettings """ super().__init__(**kwargs) self.provisioning_state = None @@ -544,6 +573,8 @@ def __init__( # pylint: disable=too-many-locals self.restore = restore self.deletion_date = None self.scheduled_purge_date = None + self.locations = locations + self.commitment_plan_associations = None class AccountSku(_serialization.Model): @@ -975,6 +1006,14 @@ class CommitmentPlan(ProxyResource): :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData :ivar etag: Resource Etag. :vartype etag: str + :ivar kind: The Kind of the resource. + :vartype kind: str + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar properties: Properties of Cognitive Services account commitment plan. :vartype properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties """ @@ -993,20 +1032,153 @@ class CommitmentPlan(ProxyResource): "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "properties": {"key": "properties", "type": "CommitmentPlanProperties"}, } - def __init__(self, *, properties: Optional["_models.CommitmentPlanProperties"] = None, **kwargs): + def __init__( + self, + *, + kind: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + properties: Optional["_models.CommitmentPlanProperties"] = None, + **kwargs + ): """ + :keyword kind: The Kind of the resource. + :paramtype kind: str + :keyword sku: The resource model definition representing SKU. + :paramtype sku: ~azure.mgmt.cognitiveservices.models.Sku + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword properties: Properties of Cognitive Services account commitment plan. :paramtype properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties """ super().__init__(**kwargs) self.system_data = None self.etag = None + self.kind = kind + self.sku = sku + self.tags = tags + self.location = location self.properties = properties +class CommitmentPlanAccountAssociation(ProxyResource): + """The commitment plan association. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar etag: Resource Etag. + :vartype etag: str + :ivar account_id: The Azure resource id of the account. + :vartype account_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "etag": {"key": "etag", "type": "str"}, + "account_id": {"key": "properties.accountId", "type": "str"}, + } + + def __init__(self, *, account_id: Optional[str] = None, **kwargs): + """ + :keyword account_id: The Azure resource id of the account. + :paramtype account_id: str + """ + super().__init__(**kwargs) + self.system_data = None + self.etag = None + self.account_id = account_id + + +class CommitmentPlanAccountAssociationListResult(_serialization.Model): + """The list of cognitive services Commitment Plan Account Association operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar next_link: The link used to get the next page of Commitment Plan Account Association. + :vartype next_link: str + :ivar value: Gets the list of Cognitive Services Commitment Plan Account Association and their + properties. + :vartype value: list[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[CommitmentPlanAccountAssociation]"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: The link used to get the next page of Commitment Plan Account Association. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.next_link = next_link + self.value = None + + +class CommitmentPlanAssociation(_serialization.Model): + """The commitment plan association. + + :ivar commitment_plan_id: The Azure resource id of the commitment plan. + :vartype commitment_plan_id: str + :ivar commitment_plan_location: The location of of the commitment plan. + :vartype commitment_plan_location: str + """ + + _attribute_map = { + "commitment_plan_id": {"key": "commitmentPlanId", "type": "str"}, + "commitment_plan_location": {"key": "commitmentPlanLocation", "type": "str"}, + } + + def __init__( + self, *, commitment_plan_id: Optional[str] = None, commitment_plan_location: Optional[str] = None, **kwargs + ): + """ + :keyword commitment_plan_id: The Azure resource id of the commitment plan. + :paramtype commitment_plan_id: str + :keyword commitment_plan_location: The location of of the commitment plan. + :paramtype commitment_plan_location: str + """ + super().__init__(**kwargs) + self.commitment_plan_id = commitment_plan_id + self.commitment_plan_location = commitment_plan_location + + class CommitmentPlanListResult(_serialization.Model): """The list of cognitive services accounts operation response. @@ -1042,6 +1214,13 @@ class CommitmentPlanProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: Gets the status of the resource at the time the operation was called. + Known values are: "Accepted", "Creating", "Deleting", "Moving", "Failed", "Succeeded", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.CommitmentPlanProvisioningState + :ivar commitment_plan_guid: Commitment plan guid. + :vartype commitment_plan_guid: str :ivar hosting_model: Account hosting model. Known values are: "Web", "ConnectedContainer", and "DisconnectedContainer". :vartype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel @@ -1058,10 +1237,13 @@ class CommitmentPlanProperties(_serialization.Model): """ _validation = { + "provisioning_state": {"readonly": True}, "last": {"readonly": True}, } _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "commitment_plan_guid": {"key": "commitmentPlanGuid", "type": "str"}, "hosting_model": {"key": "hostingModel", "type": "str"}, "plan_type": {"key": "planType", "type": "str"}, "current": {"key": "current", "type": "CommitmentPeriod"}, @@ -1073,6 +1255,7 @@ class CommitmentPlanProperties(_serialization.Model): def __init__( self, *, + commitment_plan_guid: Optional[str] = None, hosting_model: Optional[Union[str, "_models.HostingModel"]] = None, plan_type: Optional[str] = None, current: Optional["_models.CommitmentPeriod"] = None, @@ -1081,6 +1264,8 @@ def __init__( **kwargs ): """ + :keyword commitment_plan_guid: Commitment plan guid. + :paramtype commitment_plan_guid: str :keyword hosting_model: Account hosting model. Known values are: "Web", "ConnectedContainer", and "DisconnectedContainer". :paramtype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel @@ -1094,6 +1279,8 @@ def __init__( :paramtype next: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod """ super().__init__(**kwargs) + self.provisioning_state = None + self.commitment_plan_guid = commitment_plan_guid self.hosting_model = hosting_model self.plan_type = plan_type self.current = current @@ -1776,6 +1963,40 @@ def __init__(self, *, fine_tune: Optional[str] = None, inference: Optional[str] self.inference = inference +class MultiRegionSettings(_serialization.Model): + """The multiregion settings Cognitive Services account. + + :ivar routing_method: Multiregion routing methods. Known values are: "Priority", "Weighted", + and "Performance". + :vartype routing_method: str or ~azure.mgmt.cognitiveservices.models.RoutingMethods + :ivar regions: + :vartype regions: list[~azure.mgmt.cognitiveservices.models.RegionSetting] + """ + + _attribute_map = { + "routing_method": {"key": "routingMethod", "type": "str"}, + "regions": {"key": "regions", "type": "[RegionSetting]"}, + } + + def __init__( + self, + *, + routing_method: Optional[Union[str, "_models.RoutingMethods"]] = None, + regions: Optional[List["_models.RegionSetting"]] = None, + **kwargs + ): + """ + :keyword routing_method: Multiregion routing methods. Known values are: "Priority", "Weighted", + and "Performance". + :paramtype routing_method: str or ~azure.mgmt.cognitiveservices.models.RoutingMethods + :keyword regions: + :paramtype regions: list[~azure.mgmt.cognitiveservices.models.RegionSetting] + """ + super().__init__(**kwargs) + self.routing_method = routing_method + self.regions = regions + + class NetworkRuleSet(_serialization.Model): """A set of rules governing the network accessibility. @@ -1939,6 +2160,51 @@ def __init__(self, **kwargs): self.next_link = None +class PatchResourceTags(_serialization.Model): + """The object being used to update tags of a resource, in general used for PATCH operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class PatchResourceTagsAndSku(PatchResourceTags): + """The object being used to update tags and sku of a resource, in general used for PATCH operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The resource model definition representing SKU. + :paramtype sku: ~azure.mgmt.cognitiveservices.models.Sku + """ + super().__init__(tags=tags, **kwargs) + self.sku = sku + + class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. @@ -2314,6 +2580,45 @@ def __init__(self, *, key_name: Union[str, "_models.KeyName"], **kwargs): self.key_name = key_name +class RegionSetting(_serialization.Model): + """The call rate limit Cognitive Services account. + + :ivar name: Name of the region. + :vartype name: str + :ivar value: A value for priority or weighted routing methods. + :vartype value: float + :ivar customsubdomain: Maps the region to the regional custom subdomain. + :vartype customsubdomain: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "float"}, + "customsubdomain": {"key": "customsubdomain", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[float] = None, + customsubdomain: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the region. + :paramtype name: str + :keyword value: A value for priority or weighted routing methods. + :paramtype value: float + :keyword customsubdomain: Maps the region to the regional custom subdomain. + :paramtype customsubdomain: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + self.customsubdomain = customsubdomain + + class RequestMatchPattern(_serialization.Model): """RequestMatchPattern. diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py index 110082e7aa36..2a93c77cfb1e 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py @@ -18,7 +18,7 @@ from ._commitment_plans_operations import CommitmentPlansOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py index f5d42be228d7..a99a1e45362d 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,8 +30,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,8 +49,8 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +68,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,8 +87,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +106,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +125,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -138,7 +143,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -153,7 +158,7 @@ def build_get_request(resource_group_name: str, account_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +176,7 @@ def build_get_request(resource_group_name: str, account_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +191,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -201,7 +206,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -216,7 +221,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +230,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -242,7 +247,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -260,7 +265,7 @@ def build_list_keys_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -277,8 +282,8 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +301,7 @@ def build_regenerate_key_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -315,7 +320,7 @@ def build_list_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -333,7 +338,7 @@ def build_list_skus_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -350,7 +355,7 @@ def build_list_usages_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -368,7 +373,7 @@ def build_list_usages_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -387,7 +392,7 @@ def build_list_models_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -405,7 +410,7 @@ def build_list_models_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -449,9 +454,11 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -474,9 +481,9 @@ def _create_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -497,11 +504,13 @@ def _create_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @overload def begin_create( @@ -608,14 +617,16 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_initial( # type: ignore + raw_result = self._create_initial( resource_group_name=resource_group_name, account_name=account_name, account=account, @@ -635,7 +646,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -647,9 +658,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } def _update_initial( self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO], **kwargs: Any @@ -665,9 +678,11 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -690,9 +705,9 @@ def _update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -710,11 +725,13 @@ def _update_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @overload def begin_update( @@ -818,14 +835,16 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, account_name=account_name, account=account, @@ -845,7 +864,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -857,9 +876,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any @@ -875,8 +896,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -888,9 +911,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -904,7 +927,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @distributed_trace def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -930,11 +955,13 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -952,7 +979,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -964,9 +991,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @distributed_trace def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: @@ -993,8 +1022,10 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -1006,9 +1037,9 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1026,7 +1057,9 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Account"]: @@ -1043,8 +1076,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1066,7 +1101,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1082,7 +1117,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1090,13 +1125,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1110,7 +1145,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Account"]: @@ -1124,8 +1161,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Account"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1146,7 +1185,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1162,7 +1201,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1170,13 +1209,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1190,7 +1229,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts"} @distributed_trace def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ApiKeys: @@ -1217,8 +1256,10 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiKeys] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) request = build_list_keys_request( resource_group_name=resource_group_name, @@ -1230,9 +1271,9 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1250,7 +1291,9 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) return deserialized - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys" + } @distributed_trace def regenerate_key( @@ -1282,9 +1325,11 @@ def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiKeys] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) _parameters = _models.RegenerateKeyParameters(key_name=key_name) _json = self._serialize.body(_parameters, "RegenerateKeyParameters") @@ -1301,9 +1346,9 @@ def regenerate_key( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1321,7 +1366,9 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey" + } @distributed_trace def list_skus(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.AccountSkuListResult: @@ -1348,8 +1395,10 @@ def list_skus(self, resource_group_name: str, account_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountSkuListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountSkuListResult] = kwargs.pop("cls", None) request = build_list_skus_request( resource_group_name=resource_group_name, @@ -1361,9 +1410,9 @@ def list_skus(self, resource_group_name: str, account_name: str, **kwargs: Any) params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1381,7 +1430,9 @@ def list_skus(self, resource_group_name: str, account_name: str, **kwargs: Any) return deserialized - list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus"} # type: ignore + list_skus.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus" + } @distributed_trace def list_usages( @@ -1414,8 +1465,10 @@ def list_usages( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) request = build_list_usages_request( resource_group_name=resource_group_name, @@ -1428,9 +1481,9 @@ def list_usages( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1448,7 +1501,9 @@ def list_usages( return deserialized - list_usages.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages"} # type: ignore + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages" + } @distributed_trace def list_models( @@ -1469,8 +1524,10 @@ def list_models( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountModelListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountModelListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1493,7 +1550,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1509,7 +1566,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1517,13 +1574,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AccountModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1537,4 +1594,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_models.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models"} # type: ignore + list_models.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py index 02a99cbb5149..57bd507fbcdf 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ( @@ -25,8 +26,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,8 +43,8 @@ def build_check_sku_availability_request(location: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +57,7 @@ def build_check_sku_availability_request(location: str, subscription_id: str, ** "location": _SERIALIZER.url("location", location, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -69,8 +74,8 @@ def build_check_domain_availability_request(subscription_id: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +86,7 @@ def build_check_domain_availability_request(subscription_id: str, **kwargs: Any) "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +99,7 @@ def build_check_domain_availability_request(subscription_id: str, **kwargs: Any) return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class CognitiveServicesManagementClientOperationsMixin(MixinABC): +class CognitiveServicesManagementClientOperationsMixin(CognitiveServicesManagementClientMixinABC): @distributed_trace def check_sku_availability( self, location: str, skus: List[str], kind: str, type: str, **kwargs: Any @@ -125,9 +130,11 @@ def check_sku_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuAvailabilityListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.SkuAvailabilityListResult] = kwargs.pop("cls", None) _parameters = _models.CheckSkuAvailabilityParameter(kind=kind, skus=skus, type=type) _json = self._serialize.body(_parameters, "CheckSkuAvailabilityParameter") @@ -143,9 +150,9 @@ def check_sku_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -163,7 +170,9 @@ def check_sku_availability( return deserialized - check_sku_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability"} # type: ignore + check_sku_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability" + } @distributed_trace def check_domain_availability( @@ -193,9 +202,11 @@ def check_domain_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainAvailability] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.DomainAvailability] = kwargs.pop("cls", None) _parameters = _models.CheckDomainAvailabilityParameter(kind=kind, subdomain_name=subdomain_name, type=type) _json = self._serialize.body(_parameters, "CheckDomainAvailabilityParameter") @@ -210,9 +221,9 @@ def check_domain_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -230,4 +241,6 @@ def check_domain_availability( return deserialized - check_domain_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability"} # type: ignore + check_domain_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py index d54d88b0a208..5bcded7e4b43 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,8 +30,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +65,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +101,7 @@ def build_get_request( "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,8 +118,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +138,7 @@ def build_create_or_update_request( "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -152,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +176,384 @@ def build_delete_request( "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_plan_request( + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_plan_request( + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_plan_request( + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_plan_request( + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_plans_by_resource_group_request( + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_plans_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/commitmentPlans" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_associations_request( + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_association_request( + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "commitmentPlanAssociationName": _SERIALIZER.url( + "commitment_plan_association_name", + commitment_plan_association_name, + "str", + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_association_request( + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "commitmentPlanAssociationName": _SERIALIZER.url( + "commitment_plan_association_name", + commitment_plan_association_name, + "str", + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_association_request( + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "commitmentPlanName": _SERIALIZER.url( + "commitment_plan_name", commitment_plan_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" + ), + "commitmentPlanAssociationName": _SERIALIZER.url( + "commitment_plan_association_name", + commitment_plan_association_name, + "str", + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_.-]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -187,39 +569,1321 @@ class CommitmentPlansOperations: .. warning:: **DO NOT** instantiate this class directly. - Instead, you should access the following operations through - :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s - :attr:`commitment_plans` attribute. - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`commitment_plans` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.CommitmentPlan"]: + """Gets the commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommitmentPlan or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans" + } + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> _models.CommitmentPlan: + """Gets the specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlan or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlan or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlan or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, IO], + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Is either a model type or a IO type. + Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlan or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(commitment_plan, (IO, bytes)): + _content = commitment_plan + else: + _json = self._serialize.body(commitment_plan, "CommitmentPlan") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified commitmentPlan associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + } + + def _create_or_update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, IO], + **kwargs: Any + ) -> _models.CommitmentPlan: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(commitment_plan, (IO, bytes)): + _content = commitment_plan + else: + _json = self._serialize.body(commitment_plan, "CommitmentPlan") + + request = build_create_or_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_plan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_plan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @overload + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, IO], + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is either a + model type or a IO type. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + def _update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, IO], + **kwargs: Any + ) -> Optional[_models.CommitmentPlan]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(commitment_plan, (IO, bytes)): + _content = commitment_plan + else: + _json = self._serialize.body(commitment_plan, "PatchResourceTagsAndSku") + + request = build_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_plan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_plan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @overload + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.PatchResourceTagsAndSku, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, IO], + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is either a + model type or a IO type. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlan or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + def _delete_plan_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_plan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_plan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace + def begin_delete_plan(self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Cognitive Services commitment plan from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_plan_initial( # type: ignore + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace + def get_plan(self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any) -> _models.CommitmentPlan: + """Returns a Cognitive Services commitment plan specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommitmentPlan or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + request = build_get_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_plan.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CommitmentPlan", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_plan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + } + + @distributed_trace + def list_plans_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommitmentPlan or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_plans_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_plans_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_plans_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans" + } + + @distributed_trace + def list_plans_by_subscription(self, **kwargs: Any) -> Iterable["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommitmentPlan or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_plans_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_plans_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) - models = _models + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_plans_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/commitmentPlans" + } @distributed_trace - def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.CommitmentPlan"]: - """Gets the commitmentPlans associated with the Cognitive Services account. + def list_associations( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> Iterable["_models.CommitmentPlanAccountAssociation"]: + """Gets the associations of the Cognitive Services commitment plan. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param account_name: The name of Cognitive Services account. Required. - :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommitmentPlan or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :return: An iterator like instance of either CommitmentPlanAccountAssociation or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentPlanListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanAccountAssociationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -232,17 +1896,17 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + request = build_list_associations_request( resource_group_name=resource_group_name, - account_name=account_name, + commitment_plan_name=commitment_plan_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], + template_url=self.list_associations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -258,21 +1922,21 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) + deserialized = self._deserialize("CommitmentPlanAccountAssociationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -286,25 +1950,28 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans"} # type: ignore + list_associations.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations" + } @distributed_trace - def get( - self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any - ) -> _models.CommitmentPlan: - """Gets the specified commitmentPlans associated with the Cognitive Services account. + def get_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> _models.CommitmentPlanAccountAssociation: + """Gets the association of the Cognitive Services commitment plan. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param account_name: The name of Cognitive Services account. Required. - :type account_name: str :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive Services Account. Required. :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommitmentPlan or the result of cls(response) - :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :return: CommitmentPlanAccountAssociation or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -318,23 +1985,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentPlan] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) - request = build_get_request( + request = build_get_association_request( resource_group_name=resource_group_name, - account_name=account_name, commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], + template_url=self.get_association.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -345,174 +2014,271 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CommitmentPlan", pipeline_response) + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + get_association.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } + + def _create_or_update_association_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, IO], + **kwargs: Any + ) -> _models.CommitmentPlanAccountAssociation: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(association, (IO, bytes)): + _content = association + else: + _json = self._serialize.body(association, "CommitmentPlanAccountAssociation") + + request = build_create_or_update_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_association_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_association_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } @overload - def create_or_update( + def begin_create_or_update_association( self, resource_group_name: str, - account_name: str, commitment_plan_name: str, - commitment_plan: _models.CommitmentPlan, + commitment_plan_association_name: str, + association: _models.CommitmentPlanAccountAssociation, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CommitmentPlan: - """Update the state of specified commitmentPlans associated with the Cognitive Services account. + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param account_name: The name of Cognitive Services account. Required. - :type account_name: str :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive Services Account. Required. :type commitment_plan_name: str - :param commitment_plan: The commitmentPlan properties. Required. - :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommitmentPlan or the result of cls(response) - :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlanAccountAssociation or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def begin_create_or_update_association( self, resource_group_name: str, - account_name: str, commitment_plan_name: str, - commitment_plan: IO, + commitment_plan_association_name: str, + association: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CommitmentPlan: - """Update the state of specified commitmentPlans associated with the Cognitive Services account. + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param account_name: The name of Cognitive Services account. Required. - :type account_name: str :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive Services Account. Required. :type commitment_plan_name: str - :param commitment_plan: The commitmentPlan properties. Required. - :type commitment_plan: IO + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommitmentPlan or the result of cls(response) - :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlanAccountAssociation or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def begin_create_or_update_association( self, resource_group_name: str, - account_name: str, commitment_plan_name: str, - commitment_plan: Union[_models.CommitmentPlan, IO], + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, IO], **kwargs: Any - ) -> _models.CommitmentPlan: - """Update the state of specified commitmentPlans associated with the Cognitive Services account. + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param account_name: The name of Cognitive Services account. Required. - :type account_name: str :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive Services Account. Required. :type commitment_plan_name: str - :param commitment_plan: The commitmentPlan properties. Is either a model type or a IO type. + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Is either a model type or a IO type. Required. - :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or IO + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommitmentPlan or the result of cls(response) - :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CommitmentPlanAccountAssociation or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentPlan] - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(commitment_plan, (IO, bytes)): - _content = commitment_plan - else: - _json = self._serialize.body(commitment_plan, "CommitmentPlan") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - account_name=account_name, - commitment_plan_name=commitment_plan_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_association_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + association=association, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("CommitmentPlan", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CommitmentPlan", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommitmentPlanAccountAssociation", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - return deserialized + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + begin_create_or_update_association.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + def _delete_association_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any ) -> None: error_map = { 401: ClientAuthenticationError, @@ -525,23 +2291,25 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + request = build_delete_association_request( resource_group_name=resource_group_name, - account_name=account_name, commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], + template_url=self._delete_association_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -552,25 +2320,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + _delete_association_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } @distributed_trace - def begin_delete( - self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + def begin_delete_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes the specified commitmentPlan associated with the Cognitive Services account. + """Deletes the association of the Cognitive Services commitment plan. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param account_name: The name of Cognitive Services account. Required. - :type account_name: str :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive Services Account. Required. :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -586,16 +2361,18 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_association_initial( # type: ignore resource_group_name=resource_group_name, - account_name=account_name, commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -609,7 +2386,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -621,6 +2400,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}"} # type: ignore + begin_delete_association.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py index b07ad81648c2..8abb41019fd5 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -27,8 +28,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +58,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht "location": _SERIALIZER.url("location", location, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,8 +102,10 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.CommitmentTier _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.CommitmentTierListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.CommitmentTierListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -120,7 +127,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -136,7 +143,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -144,13 +151,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("CommitmentTierListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -164,4 +171,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/commitmentTiers"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/commitmentTiers" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py index bd60a6f759c3..4cd7ed1a88c7 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast import urllib.parse @@ -29,8 +30,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +68,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +85,7 @@ def build_purge_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +104,7 @@ def build_purge_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +119,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +130,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -182,8 +187,10 @@ def get(self, location: str, resource_group_name: str, account_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) request = build_get_request( location=location, @@ -196,9 +203,9 @@ def get(self, location: str, resource_group_name: str, account_name: str, **kwar params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -216,7 +223,9 @@ def get(self, location: str, resource_group_name: str, account_name: str, **kwar return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + } def _purge_initial( # pylint: disable=inconsistent-return-statements self, location: str, resource_group_name: str, account_name: str, **kwargs: Any @@ -232,8 +241,10 @@ def _purge_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_purge_request( location=location, @@ -246,9 +257,9 @@ def _purge_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -262,7 +273,9 @@ def _purge_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _purge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}"} # type: ignore + _purge_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + } @distributed_trace def begin_purge(self, location: str, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -290,11 +303,13 @@ def begin_purge(self, location: str, resource_group_name: str, account_name: str _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._purge_initial( # type: ignore location=location, @@ -313,7 +328,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -325,9 +340,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_purge.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}"} # type: ignore + begin_purge.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Account"]: @@ -341,8 +358,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Account"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.AccountListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -363,7 +382,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -379,7 +398,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -387,13 +406,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -407,4 +426,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/deletedAccounts"} diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py index 6ace35208eb8..43631ced1228 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,8 +30,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +65,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +101,7 @@ def build_get_request( "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,8 +118,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +138,7 @@ def build_create_or_update_request( "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -152,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +176,7 @@ def build_delete_request( "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -218,8 +223,10 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.DeploymentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -242,7 +249,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -258,7 +265,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -266,13 +273,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -286,7 +293,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments" + } @distributed_trace def get( @@ -318,8 +327,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Deployment] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -332,9 +343,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -352,7 +363,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } def _create_or_update_initial( self, @@ -373,9 +386,11 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Deployment] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -399,9 +414,9 @@ def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -419,11 +434,13 @@ def _create_or_update_initial( deserialized = self._deserialize("Deployment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } @overload def begin_create_or_update( @@ -542,14 +559,16 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Deployment] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, deployment_name=deployment_name, @@ -570,7 +589,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -582,9 +601,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any @@ -600,8 +621,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -614,9 +637,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -630,7 +653,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } @distributed_trace def begin_delete( @@ -661,11 +686,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -684,7 +711,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -696,6 +723,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py index 88e8f9fc6d9e..b8166b216c9e 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -27,8 +28,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,8 +91,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -107,7 +114,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -123,7 +130,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,13 +138,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,4 +158,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.CognitiveServices/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.CognitiveServices/operations"} diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py index a3bf366a0ba0..1a06604a5d46 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -27,8 +28,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +63,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +84,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +105,7 @@ def build_get_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,8 +126,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +148,7 @@ def build_create_or_update_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,7 +171,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_delete_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -244,8 +249,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) request = build_list_request( resource_group_name=resource_group_name, @@ -257,9 +264,9 @@ def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -277,7 +284,9 @@ def list( return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections" + } @distributed_trace def get( @@ -309,8 +318,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -323,9 +334,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -343,7 +354,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, @@ -364,9 +377,11 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -390,9 +405,9 @@ def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -410,11 +425,13 @@ def _create_or_update_initial( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @overload def begin_create_or_update( @@ -543,14 +560,16 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -571,7 +590,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -583,9 +602,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -601,8 +622,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -615,9 +638,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -631,7 +654,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def begin_delete( @@ -663,11 +688,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -686,7 +713,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -698,6 +725,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py index 43c526fdd5d0..f57508577be7 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -25,8 +26,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -56,7 +61,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,8 +116,10 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) request = build_list_request( resource_group_name=resource_group_name, @@ -124,9 +131,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -144,4 +151,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources" + } diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py index 1bb01a625023..83299834779d 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -27,8 +28,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import MixinABC, _convert_request, _format_url_section +from .._vendor import CognitiveServicesManagementClientMixinABC, _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,8 +96,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.ResourceSku"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuListResult] + api_version: Literal["2022-12-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ResourceSkuListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -113,7 +120,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -129,7 +136,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -137,13 +144,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -157,4 +164,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus"} diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account.py new file mode 100644 index 000000000000..57990b8a7314 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account.py @@ -0,0 +1,62 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python create_account.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.begin_create( + resource_group_name="myResourceGroup", + account_name="testCreate1", + account={ + "identity": {"type": "SystemAssigned"}, + "kind": "Emotion", + "location": "West US", + "properties": { + "encryption": { + "keySource": "Microsoft.KeyVault", + "keyVaultProperties": { + "keyName": "KeyName", + "keyVaultUri": "https://pltfrmscrts-use-pc-dev.vault.azure.net/", + "keyVersion": "891CF236-D241-4738-9462-D506AF493DFA", + }, + }, + "userOwnedStorage": [ + { + "resourceId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount" + } + ], + }, + "sku": {"name": "S0"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/CreateAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account_min.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account_min.py new file mode 100644 index 000000000000..e4fb3283b8de --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_account_min.py @@ -0,0 +1,48 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python create_account_min.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.begin_create( + resource_group_name="myResourceGroup", + account_name="testCreate1", + account={ + "identity": {"type": "SystemAssigned"}, + "kind": "CognitiveServices", + "location": "West US", + "properties": {}, + "sku": {"name": "S0"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/CreateAccountMin.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan.py new file mode 100644 index 000000000000..7f18cfa73cf1 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python create_shared_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.begin_create_or_update_plan( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + commitment_plan={ + "kind": "SpeechServices", + "location": "West US", + "properties": {"autoRenew": True, "current": {"tier": "T1"}, "hostingModel": "Web", "planType": "STT"}, + "sku": {"name": "S0"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/CreateSharedCommitmentPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan_association.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan_association.py new file mode 100644 index 000000000000..e3439d3937c6 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/create_shared_commitment_plan_association.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python create_shared_commitment_plan_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.begin_create_or_update_association( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + commitment_plan_association_name="commitmentPlanAssociationName", + association={ + "properties": { + "accountId": "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName" + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/CreateSharedCommitmentPlanAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_account.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_account.py new file mode 100644 index 000000000000..935fd2fa1d90 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_account.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python delete_account.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.begin_delete( + resource_group_name="myResourceGroup", + account_name="PropTest01", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/DeleteAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_commitment_plan.py new file mode 100644 index 000000000000..02d6e018ea33 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_commitment_plan.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python delete_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.commitment_plans.begin_delete( + resource_group_name="resourceGroupName", + account_name="accountName", + commitment_plan_name="commitmentPlanName", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/DeleteCommitmentPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_deployment.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_deployment.py new file mode 100644 index 000000000000..7969ae03846a --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_deployment.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python delete_deployment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.deployments.begin_delete( + resource_group_name="resourceGroupName", + account_name="accountName", + deployment_name="deploymentName", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/DeleteDeployment.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_private_endpoint_connection.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_private_endpoint_connection.py new file mode 100644 index 000000000000..cd4a4522c81f --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_private_endpoint_connection.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python delete_private_endpoint_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.private_endpoint_connections.begin_delete( + resource_group_name="res6977", + account_name="sto2527", + private_endpoint_connection_name="{privateEndpointConnectionName}", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/DeletePrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan.py new file mode 100644 index 000000000000..e0cc7daa3e59 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python delete_shared_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.begin_delete_plan( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/DeleteSharedCommitmentPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan_association.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan_association.py new file mode 100644 index 000000000000..bfc85ed2ec62 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/delete_shared_commitment_plan_association.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python delete_shared_commitment_plan_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.begin_delete_association( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + commitment_plan_association_name="commitmentPlanAssociationName", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/DeleteSharedCommitmentPlanAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_account.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_account.py new file mode 100644 index 000000000000..1ad031875e47 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_account.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_account.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.get( + resource_group_name="myResourceGroup", + account_name="myAccount", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_commitment_plan.py new file mode 100644 index 000000000000..1bab99af1007 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_commitment_plan.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.commitment_plans.get( + resource_group_name="resourceGroupName", + account_name="accountName", + commitment_plan_name="commitmentPlanName", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetCommitmentPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deleted_account.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deleted_account.py new file mode 100644 index 000000000000..521f5e2f37df --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deleted_account.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_deleted_account.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.deleted_accounts.get( + location="westus", + resource_group_name="myResourceGroup", + account_name="myAccount", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetDeletedAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deployment.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deployment.py new file mode 100644 index 000000000000..7a11b6e87726 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_deployment.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_deployment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.deployments.get( + resource_group_name="resourceGroupName", + account_name="accountName", + deployment_name="deploymentName", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetDeployment.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_operations.py new file mode 100644 index 000000000000..fd2d644ef85f --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_operations.py @@ -0,0 +1,39 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_private_endpoint_connection.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_private_endpoint_connection.py new file mode 100644 index 000000000000..fce8982d0190 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_private_endpoint_connection.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_private_endpoint_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.private_endpoint_connections.get( + resource_group_name="res6977", + account_name="sto2527", + private_endpoint_connection_name="{privateEndpointConnectionName}", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetPrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan.py new file mode 100644 index 000000000000..9a4ef398fc07 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_shared_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.get_plan( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetSharedCommitmentPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan_association.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan_association.py new file mode 100644 index 000000000000..0bfb3172c151 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_shared_commitment_plan_association.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_shared_commitment_plan_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.get_association( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + commitment_plan_association_name="commitmentPlanAssociationName", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetSharedCommitmentPlanAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_skus.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_skus.py new file mode 100644 index 000000000000..e91b99f04625 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_skus.py @@ -0,0 +1,39 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_skus.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="f1c637e4-72ec-4f89-8d2b-0f933c036002", + ) + + response = client.resource_skus.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetSkus.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_usages.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_usages.py new file mode 100644 index 000000000000..8dc8998c99a2 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/get_usages.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python get_usages.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5a4f5c2e-6983-4ccb-bd34-2196d5b5bbd3", + ) + + response = client.accounts.list_usages( + resource_group_name="myResourceGroup", + account_name="TestUsage02", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/GetUsages.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_account_models.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_account_models.py new file mode 100644 index 000000000000..66b5a27640b6 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_account_models.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_account_models.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.accounts.list_models( + resource_group_name="resourceGroupName", + account_name="accountName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListAccountModels.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_resource_group.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_resource_group.py new file mode 100644 index 000000000000..c216eabe6386 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_resource_group.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_accounts_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListAccountsByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_subscription.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_subscription.py new file mode 100644 index 000000000000..94ccb989ae01 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_accounts_by_subscription.py @@ -0,0 +1,39 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_accounts_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListAccountsBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_plans.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_plans.py new file mode 100644 index 000000000000..7ca095ee23e8 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_plans.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_commitment_plans.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.commitment_plans.list( + resource_group_name="resourceGroupName", + account_name="accountName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListCommitmentPlans.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_tiers.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_tiers.py new file mode 100644 index 000000000000..343fb747d9bb --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_commitment_tiers.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_commitment_tiers.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.commitment_tiers.list( + location="location", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListCommitmentTiers.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deleted_accounts_by_subscription.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deleted_accounts_by_subscription.py new file mode 100644 index 000000000000..e2c1ad29cdbd --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deleted_accounts_by_subscription.py @@ -0,0 +1,39 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_deleted_accounts_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.deleted_accounts.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListDeletedAccountsBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deployments.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deployments.py new file mode 100644 index 000000000000..dd7ab75382a2 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_deployments.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_deployments.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.deployments.list( + resource_group_name="resourceGroupName", + account_name="accountName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListDeployments.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_keys.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_keys.py new file mode 100644 index 000000000000..350c7fcf2182 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_keys.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_keys.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.list_keys( + resource_group_name="myResourceGroup", + account_name="myAccount", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListKeys.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_endpoint_connections.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_endpoint_connections.py new file mode 100644 index 000000000000..71ce89cec2b2 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_endpoint_connections.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_private_endpoint_connections.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.private_endpoint_connections.list( + resource_group_name="res6977", + account_name="sto2527", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListPrivateEndpointConnections.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_link_resources.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_link_resources.py new file mode 100644 index 000000000000..098857a7488b --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_private_link_resources.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_private_link_resources.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.private_link_resources.list( + resource_group_name="res6977", + account_name="sto2527", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListPrivateLinkResources.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plan_associations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plan_associations.py new file mode 100644 index 000000000000..60f95b2db5e9 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plan_associations.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_shared_commitment_plan_associations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.list_associations( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListSharedCommitmentPlanAssociations.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_resource_group.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_resource_group.py new file mode 100644 index 000000000000..09bf0aafaee0 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_resource_group.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_shared_commitment_plans_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.list_plans_by_resource_group( + resource_group_name="resourceGroupName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListSharedCommitmentPlansByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_subscription.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_subscription.py new file mode 100644 index 000000000000..fd85da2fdbb3 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_shared_commitment_plans_by_subscription.py @@ -0,0 +1,39 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_shared_commitment_plans_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.list_plans_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListSharedCommitmentPlansBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_skus.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_skus.py new file mode 100644 index 000000000000..10520d97695e --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/list_skus.py @@ -0,0 +1,41 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python list_skus.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.list_skus( + resource_group_name="myResourceGroup", + account_name="myAccount", + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/ListSkus.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/purge_deleted_account.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/purge_deleted_account.py new file mode 100644 index 000000000000..690481609517 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/purge_deleted_account.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python purge_deleted_account.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.deleted_accounts.begin_purge( + location="westus", + resource_group_name="myResourceGroup", + account_name="PropTest01", + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/PurgeDeletedAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_commitment_plan.py new file mode 100644 index 000000000000..04346729c968 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_commitment_plan.py @@ -0,0 +1,50 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python put_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.commitment_plans.create_or_update( + resource_group_name="resourceGroupName", + account_name="accountName", + commitment_plan_name="commitmentPlanName", + commitment_plan={ + "properties": { + "autoRenew": True, + "current": {"tier": "T1"}, + "hostingModel": "Web", + "planType": "Speech2Text", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/PutCommitmentPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_deployment.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_deployment.py new file mode 100644 index 000000000000..3ca377634a6d --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_deployment.py @@ -0,0 +1,48 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python put_deployment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subscriptionId", + ) + + response = client.deployments.begin_create_or_update( + resource_group_name="resourceGroupName", + account_name="accountName", + deployment_name="deploymentName", + deployment={ + "properties": { + "model": {"format": "OpenAI", "name": "ada", "version": "1"}, + "scaleSettings": {"capacity": 1, "scaleType": "Manual"}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/PutDeployment.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_private_endpoint_connection.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_private_endpoint_connection.py new file mode 100644 index 000000000000..c7a4fc3351cc --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/put_private_endpoint_connection.py @@ -0,0 +1,45 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python put_private_endpoint_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.private_endpoint_connections.begin_create_or_update( + resource_group_name="res7687", + account_name="sto9699", + private_endpoint_connection_name="{privateEndpointConnectionName}", + properties={ + "properties": {"privateLinkServiceConnectionState": {"description": "Auto-Approved", "status": "Approved"}} + }, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/PutPrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_account.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_account.py new file mode 100644 index 000000000000..72291a37aff7 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_account.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python update_account.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.accounts.begin_update( + resource_group_name="bvttest", + account_name="bingSearch", + account={"location": "global", "sku": {"name": "S2"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/UpdateAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_shared_commitment_plan.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_shared_commitment_plan.py new file mode 100644 index 000000000000..1fcbb3ccb421 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/generated_samples/update_shared_commitment_plan.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cognitiveservices +# USAGE + python update_shared_commitment_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CognitiveServicesManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.commitment_plans.begin_update_plan( + resource_group_name="resourceGroupName", + commitment_plan_name="commitmentPlanName", + commitment_plan={"tags": {"name": "value"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-12-01/examples/UpdateSharedCommitmentPlan.json +if __name__ == "__main__": + main()