From 280eb273f9f12839cd90ca554e51145b21bd7d0b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 1 Sep 2022 01:22:19 +0000 Subject: [PATCH] CodeGen from PR 20489 in Azure/azure-rest-api-specs Merge bb00fa54ec111721e1822dcad66bc3c85cf4b7b2 into 7c840caa77ac200f43636930d82fc31cf117241e --- sdk/media/azure-mgmt-media/_meta.json | 10 +- .../azure/mgmt/media/__init__.py | 3 +- .../azure/mgmt/media/_azure_media_services.py | 90 +- .../azure/mgmt/media/_configuration.py | 46 +- .../azure/mgmt/media/_patch.py | 2 +- .../azure/mgmt/media/_serialization.py | 1970 ++++++ .../azure/mgmt/media/_vendor.py | 6 +- .../azure/mgmt/media/_version.py | 2 +- .../azure/mgmt/media/aio/__init__.py | 3 +- .../mgmt/media/aio/_azure_media_services.py | 90 +- .../azure/mgmt/media/aio/_configuration.py | 48 +- .../azure/mgmt/media/aio/_patch.py | 2 +- .../mgmt/media/aio/operations/__init__.py | 45 +- .../operations/_account_filters_operations.py | 395 +- .../operations/_asset_filters_operations.py | 420 +- .../aio/operations/_assets_operations.py | 597 +- .../_content_key_policies_operations.py | 436 +- .../media/aio/operations/_jobs_operations.py | 461 +- .../aio/operations/_live_events_operations.py | 1139 ++-- .../operations/_live_outputs_operations.py | 544 +- .../aio/operations/_locations_operations.py | 109 +- ...a_services_operation_results_operations.py | 62 +- ..._services_operation_statuses_operations.py | 53 +- .../operations/_mediaservices_operations.py | 809 ++- .../_operation_results_operations.py | 60 +- .../_operation_statuses_operations.py | 51 +- .../mgmt/media/aio/operations/_operations.py | 45 +- .../azure/mgmt/media/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 256 +- .../_private_link_resources_operations.py | 90 +- .../_streaming_endpoints_operations.py | 1104 ++-- .../_streaming_locators_operations.py | 357 +- .../_streaming_policies_operations.py | 275 +- .../aio/operations/_tracks_operations.py | 746 ++- .../aio/operations/_transforms_operations.py | 392 +- .../azure/mgmt/media/models/__init__.py | 684 +- .../models/_azure_media_services_enums.py | 278 +- .../azure/mgmt/media/models/_models_py3.py | 5856 ++++++++--------- .../azure/mgmt/media/models/_patch.py | 1 + .../azure/mgmt/media/operations/__init__.py | 45 +- .../operations/_account_filters_operations.py | 586 +- .../operations/_asset_filters_operations.py | 625 +- .../media/operations/_assets_operations.py | 899 +-- .../_content_key_policies_operations.py | 660 +- .../mgmt/media/operations/_jobs_operations.py | 701 +- .../operations/_live_events_operations.py | 1604 +++-- .../operations/_live_outputs_operations.py | 817 ++- .../media/operations/_locations_operations.py | 155 +- ...a_services_operation_results_operations.py | 100 +- ..._services_operation_statuses_operations.py | 91 +- .../operations/_mediaservices_operations.py | 1114 ++-- .../_operation_results_operations.py | 99 +- .../_operation_statuses_operations.py | 90 +- .../mgmt/media/operations/_operations.py | 69 +- .../azure/mgmt/media/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 401 +- .../_private_link_resources_operations.py | 167 +- .../_streaming_endpoints_operations.py | 1574 +++-- .../_streaming_locators_operations.py | 572 +- .../_streaming_policies_operations.py | 422 +- .../media/operations/_tracks_operations.py | 1014 +-- .../operations/_transforms_operations.py | 585 +- 62 files changed, 17889 insertions(+), 12040 deletions(-) create mode 100644 sdk/media/azure-mgmt-media/azure/mgmt/media/_serialization.py diff --git a/sdk/media/azure-mgmt-media/_meta.json b/sdk/media/azure-mgmt-media/_meta.json index 58788c594b9c..7fee940978cf 100644 --- a/sdk/media/azure-mgmt-media/_meta.json +++ b/sdk/media/azure-mgmt-media/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.0.1", + "@autorest/modelerfour@4.23.5" ], - "commit": "fda2db441da3f1fab31bb235e97da3e33c8e3903", + "commit": "ad59b7f8972ec69f2778bcff7f0531ca8c937907", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/mediaservices/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/mediaservices/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/mediaservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/__init__.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/__init__.py index 47684d77705e..85e106868ea3 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/__init__.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['AzureMediaServices'] + +__all__ = ["AzureMediaServices"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/_azure_media_services.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/_azure_media_services.py index e1d25487e0a0..7805d58c1fa3 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/_azure_media_services.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/_azure_media_services.py @@ -9,20 +9,42 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models from ._configuration import AzureMediaServicesConfiguration -from .operations import AccountFiltersOperations, AssetFiltersOperations, AssetsOperations, ContentKeyPoliciesOperations, JobsOperations, LiveEventsOperations, LiveOutputsOperations, LocationsOperations, MediaServicesOperationResultsOperations, MediaServicesOperationStatusesOperations, MediaservicesOperations, OperationResultsOperations, OperationStatusesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, StreamingEndpointsOperations, StreamingLocatorsOperations, StreamingPoliciesOperations, TracksOperations, TransformsOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + AccountFiltersOperations, + AssetFiltersOperations, + AssetsOperations, + ContentKeyPoliciesOperations, + JobsOperations, + LiveEventsOperations, + LiveOutputsOperations, + LocationsOperations, + MediaServicesOperationResultsOperations, + MediaServicesOperationStatusesOperations, + MediaservicesOperations, + OperationResultsOperations, + OperationStatusesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + StreamingEndpointsOperations, + StreamingLocatorsOperations, + StreamingPoliciesOperations, + TracksOperations, + TransformsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AzureMediaServices: # pylint: disable=too-many-instance-attributes + +class AzureMediaServices: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """This Swagger was generated by the API Framework. :ivar account_filters: AccountFiltersOperations operations @@ -70,15 +92,12 @@ class AzureMediaServices: # pylint: disable=too-many-instance-attributes :vartype live_outputs: azure.mgmt.media.operations.LiveOutputsOperations :ivar streaming_endpoints: StreamingEndpointsOperations operations :vartype streaming_endpoints: azure.mgmt.media.operations.StreamingEndpointsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The unique identifier for a Microsoft Azure subscription. + :param subscription_id: The unique identifier for a Microsoft Azure subscription. Required. :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 "2021-11-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 Retry-After header is present. """ @@ -97,39 +116,25 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.account_filters = AccountFiltersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.mediaservices = MediaservicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.account_filters = AccountFiltersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.mediaservices = MediaservicesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) self.media_services_operation_statuses = MediaServicesOperationStatusesOperations( self._client, self._config, self._serialize, self._deserialize ) self.media_services_operation_results = MediaServicesOperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.assets = AssetsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.asset_filters = AssetFiltersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.tracks = TracksOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asset_filters = AssetFiltersOperations(self._client, self._config, self._serialize, self._deserialize) + self.tracks = TracksOperations(self._client, self._config, self._serialize, self._deserialize) self.operation_statuses = OperationStatusesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -139,34 +144,21 @@ def __init__( self.content_key_policies = ContentKeyPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transforms = TransformsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.transforms = TransformsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.streaming_policies = StreamingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) self.streaming_locators = StreamingLocatorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.live_events = LiveEventsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.live_outputs = LiveOutputsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.live_events = LiveEventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.live_outputs = LiveOutputsOperations(self._client, self._config, self._serialize, self._deserialize) self.streaming_endpoints = StreamingEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -175,7 +167,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/_configuration.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/_configuration.py index eb3f0be6a11b..c6371fecbf0c 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/_configuration.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/_configuration.py @@ -25,24 +25,14 @@ class AzureMediaServicesConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The unique identifier for a Microsoft Azure subscription. + :param subscription_id: The unique identifier for a Microsoft Azure subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-11-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AzureMediaServicesConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -50,24 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-media/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-media/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/_patch.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/_patch.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/_serialization.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/_serialization.py new file mode 100644 index 000000000000..648f84cc4e65 --- /dev/null +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +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: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/_vendor.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/_vendor.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/_version.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/_version.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/__init__.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/__init__.py index c58317cfbdb3..a2812ba27461 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/__init__.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['AzureMediaServices'] + +__all__ = ["AzureMediaServices"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_azure_media_services.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_azure_media_services.py index 8d35eaa8128a..7b8c31f28cd7 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_azure_media_services.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_azure_media_services.py @@ -9,20 +9,42 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import AzureMediaServicesConfiguration -from .operations import AccountFiltersOperations, AssetFiltersOperations, AssetsOperations, ContentKeyPoliciesOperations, JobsOperations, LiveEventsOperations, LiveOutputsOperations, LocationsOperations, MediaServicesOperationResultsOperations, MediaServicesOperationStatusesOperations, MediaservicesOperations, OperationResultsOperations, OperationStatusesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, StreamingEndpointsOperations, StreamingLocatorsOperations, StreamingPoliciesOperations, TracksOperations, TransformsOperations +from .operations import ( + AccountFiltersOperations, + AssetFiltersOperations, + AssetsOperations, + ContentKeyPoliciesOperations, + JobsOperations, + LiveEventsOperations, + LiveOutputsOperations, + LocationsOperations, + MediaServicesOperationResultsOperations, + MediaServicesOperationStatusesOperations, + MediaservicesOperations, + OperationResultsOperations, + OperationStatusesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + StreamingEndpointsOperations, + StreamingLocatorsOperations, + StreamingPoliciesOperations, + TracksOperations, + TransformsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AzureMediaServices: # pylint: disable=too-many-instance-attributes + +class AzureMediaServices: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """This Swagger was generated by the API Framework. :ivar account_filters: AccountFiltersOperations operations @@ -70,15 +92,12 @@ class AzureMediaServices: # pylint: disable=too-many-instance-attributes :vartype live_outputs: azure.mgmt.media.aio.operations.LiveOutputsOperations :ivar streaming_endpoints: StreamingEndpointsOperations operations :vartype streaming_endpoints: azure.mgmt.media.aio.operations.StreamingEndpointsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The unique identifier for a Microsoft Azure subscription. + :param subscription_id: The unique identifier for a Microsoft Azure subscription. Required. :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 "2021-11-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 Retry-After header is present. """ @@ -97,39 +116,25 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.account_filters = AccountFiltersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.mediaservices = MediaservicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.account_filters = AccountFiltersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.mediaservices = MediaservicesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) self.media_services_operation_statuses = MediaServicesOperationStatusesOperations( self._client, self._config, self._serialize, self._deserialize ) self.media_services_operation_results = MediaServicesOperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.assets = AssetsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.asset_filters = AssetFiltersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.tracks = TracksOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asset_filters = AssetFiltersOperations(self._client, self._config, self._serialize, self._deserialize) + self.tracks = TracksOperations(self._client, self._config, self._serialize, self._deserialize) self.operation_statuses = OperationStatusesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -139,34 +144,21 @@ def __init__( self.content_key_policies = ContentKeyPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transforms = TransformsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.transforms = TransformsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.streaming_policies = StreamingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) self.streaming_locators = StreamingLocatorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.live_events = LiveEventsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.live_outputs = LiveOutputsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.live_events = LiveEventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.live_outputs = LiveOutputsOperations(self._client, self._config, self._serialize, self._deserialize) self.streaming_endpoints = StreamingEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -175,7 +167,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_configuration.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_configuration.py index fa15af4dda01..be0688aad261 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_configuration.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_configuration.py @@ -25,24 +25,14 @@ class AzureMediaServicesConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The unique identifier for a Microsoft Azure subscription. + :param subscription_id: The unique identifier for a Microsoft Azure subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-11-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AzureMediaServicesConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -50,23 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-media/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-media/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_patch.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_patch.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/__init__.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/__init__.py index 1aefc8bfa770..bf9127707638 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/__init__.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/__init__.py @@ -31,28 +31,29 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountFiltersOperations', - 'Operations', - 'MediaservicesOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', - 'LocationsOperations', - 'MediaServicesOperationStatusesOperations', - 'MediaServicesOperationResultsOperations', - 'AssetsOperations', - 'AssetFiltersOperations', - 'TracksOperations', - 'OperationStatusesOperations', - 'OperationResultsOperations', - 'ContentKeyPoliciesOperations', - 'TransformsOperations', - 'JobsOperations', - 'StreamingPoliciesOperations', - 'StreamingLocatorsOperations', - 'LiveEventsOperations', - 'LiveOutputsOperations', - 'StreamingEndpointsOperations', + "AccountFiltersOperations", + "Operations", + "MediaservicesOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "LocationsOperations", + "MediaServicesOperationStatusesOperations", + "MediaServicesOperationResultsOperations", + "AssetsOperations", + "AssetFiltersOperations", + "TracksOperations", + "OperationStatusesOperations", + "OperationResultsOperations", + "ContentKeyPoliciesOperations", + "TransformsOperations", + "JobsOperations", + "StreamingPoliciesOperations", + "StreamingLocatorsOperations", + "LiveEventsOperations", + "LiveOutputsOperations", + "StreamingEndpointsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_account_filters_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_account_filters_operations.py index b628563a63fd..1a582e61615b 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_account_filters_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_account_filters_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,18 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._account_filters_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._account_filters_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AccountFiltersOperations: """ .. warning:: @@ -43,48 +57,42 @@ def __init__(self, *args, **kwargs) -> None: 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 - ) -> AsyncIterable[_models.AccountFilterCollection]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AccountFilter"]: """List Account Filters. List Account Filters in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. 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 AccountFilterCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AccountFilterCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AccountFilter or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AccountFilter] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilterCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountFilterCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +100,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +116,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,54 +128,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, filter_name: str, **kwargs: Any ) -> _models.AccountFilter: """Get an Account Filter. Get the details of an Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccountFilter, or the result of cls(response) + :return: AccountFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AccountFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilter] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountFilter] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -186,10 +175,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -197,23 +185,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, filter_name: str, parameters: _models.AccountFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccountFilter: """Create or update an Account Filter. @@ -221,41 +210,114 @@ async def create_or_update( Creates or updates an Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AccountFilter + :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: AccountFilter, or the result of cls(response) + :return: AccountFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AccountFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccountFilter: + """Create or update an Account Filter. + + Creates or updates an Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: Union[_models.AccountFilter, IO], + **kwargs: Any + ) -> _models.AccountFilter: + """Create or update an Account Filter. + + Creates or updates an Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AccountFilter 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilter] + 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.AccountFilter] - _json = self._serialize.body(parameters, 'AccountFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountFilter") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -263,10 +325,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -275,61 +336,54 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, filter_name: str, **kwargs: Any ) -> None: """Delete an Account Filter. Deletes an Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -337,10 +391,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -351,16 +404,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, filter_name: str, parameters: _models.AccountFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccountFilter: """Update an Account Filter. @@ -368,41 +422,114 @@ async def update( Updates an existing Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AccountFilter + :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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccountFilter: + """Update an Account Filter. + + Updates an existing Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AccountFilter, or the result of cls(response) + :return: AccountFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AccountFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: Union[_models.AccountFilter, IO], + **kwargs: Any + ) -> _models.AccountFilter: + """Update an Account Filter. + + Updates an existing Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AccountFilter 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilter] + 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.AccountFilter] - _json = self._serialize.body(parameters, 'AccountFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountFilter") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +537,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,12 +547,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_asset_filters_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_asset_filters_operations.py index 69c183eb05a2..1fccabce67bd 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_asset_filters_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_asset_filters_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,18 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._asset_filters_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._asset_filters_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AssetFiltersOperations: """ .. warning:: @@ -43,51 +57,45 @@ def __init__(self, *args, **kwargs) -> None: 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, - asset_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AssetFilterCollection]: + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AssetFilter"]: """List Asset Filters. List Asset Filters associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AssetFilterCollection or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AssetFilterCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AssetFilter or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AssetFilter] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilterCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetFilterCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -95,17 +103,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - asset_name=asset_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -121,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -135,58 +131,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, filter_name: str, **kwargs: Any ) -> _models.AssetFilter: """Get an Asset Filter. Get the details of an Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetFilter, or the result of cls(response) + :return: AssetFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilter] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetFilter] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -194,10 +181,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,17 +191,16 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -223,6 +208,8 @@ async def create_or_update( asset_name: str, filter_name: str, parameters: _models.AssetFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AssetFilter: """Create or update an Asset Filter. @@ -230,44 +217,123 @@ async def create_or_update( Creates or updates an Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetFilter + :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: AssetFilter, or the result of cls(response) + :return: AssetFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AssetFilter: + """Create or update an Asset Filter. + + Creates or updates an Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: Union[_models.AssetFilter, IO], + **kwargs: Any + ) -> _models.AssetFilter: + """Create or update an Asset Filter. + + Creates or updates an Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetFilter 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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilter] + 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.AssetFilter] - _json = self._serialize.body(parameters, 'AssetFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetFilter") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -275,10 +341,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -287,65 +352,57 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, filter_name: str, **kwargs: Any ) -> None: """Delete an Asset Filter. Deletes an Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -353,10 +410,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -367,10 +423,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, @@ -378,6 +433,8 @@ async def update( asset_name: str, filter_name: str, parameters: _models.AssetFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AssetFilter: """Update an Asset Filter. @@ -385,44 +442,123 @@ async def update( Updates an existing Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetFilter + :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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AssetFilter: + """Update an Asset Filter. + + Updates an existing Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: Union[_models.AssetFilter, IO], + **kwargs: Any + ) -> _models.AssetFilter: + """Update an Asset Filter. + + Updates an existing Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetFilter 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: AssetFilter, or the result of cls(response) + :return: AssetFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilter] + 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.AssetFilter] - _json = self._serialize.body(parameters, 'AssetFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetFilter") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -430,10 +566,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,12 +576,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_assets_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_assets_operations.py index 666912caf206..e5ab6d45ff23 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_assets_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_assets_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._assets_operations import build_create_or_update_request, build_delete_request, build_get_encryption_key_request, build_get_request, build_list_container_sas_request, build_list_request, build_list_streaming_locators_request, build_update_request -T = TypeVar('T') +from ...operations._assets_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_encryption_key_request, + build_get_request, + build_list_container_sas_request, + build_list_request, + build_list_streaming_locators_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AssetsOperations: """ .. warning:: @@ -43,7 +60,6 @@ def __init__(self, *args, **kwargs) -> None: 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, @@ -53,14 +69,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.AssetCollection]: + ) -> AsyncIterable["_models.Asset"]: """List Assets. List Assets in the Media Services account with optional filtering and ordering. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -72,32 +89,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AssetCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AssetCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Asset or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.Asset] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +121,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +137,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,54 +149,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any - ) -> _models.Asset: + async def get(self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any) -> _models.Asset: """Get an Asset. Get the details of an Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Asset, or the result of cls(response) + :return: Asset or the result of cls(response) :rtype: ~azure.mgmt.media.models.Asset - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Asset] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Asset] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -202,10 +194,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -213,23 +204,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, asset_name: str, parameters: _models.Asset, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Asset: """Create or update an Asset. @@ -237,41 +229,114 @@ async def create_or_update( Creates or updates an Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Asset + :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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Asset: + """Create or update an Asset. + + Creates or updates an Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: Union[_models.Asset, IO], + **kwargs: Any + ) -> _models.Asset: + """Create or update an Asset. + + Creates or updates an Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Asset 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: Asset, or the result of cls(response) + :return: Asset or the result of cls(response) :rtype: ~azure.mgmt.media.models.Asset - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Asset] + 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.Asset] - _json = self._serialize.body(parameters, 'Asset') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Asset") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -279,10 +344,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -291,61 +355,54 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any ) -> None: """Delete an Asset. Deletes an Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -353,10 +410,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -367,16 +423,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, asset_name: str, parameters: _models.Asset, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Asset: """Update an Asset. @@ -384,41 +441,114 @@ async def update( Updates an existing Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Asset + :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: Asset, or the result of cls(response) + :return: Asset or the result of cls(response) :rtype: ~azure.mgmt.media.models.Asset - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Asset: + """Update an Asset. + + Updates an existing Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: Union[_models.Asset, IO], + **kwargs: Any + ) -> _models.Asset: + """Update an Asset. + + Updates an existing Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Asset 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Asset] + 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.Asset] - _json = self._serialize.body(parameters, 'Asset') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Asset") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -426,10 +556,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,23 +566,24 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - - @distributed_trace_async + @overload async def list_container_sas( self, resource_group_name: str, account_name: str, asset_name: str, parameters: _models.ListContainerSasInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AssetContainerSas: """List the Asset URLs. @@ -462,41 +592,116 @@ async def list_container_sas( Asset content. The signatures are derived from the storage account keys. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ListContainerSasInput + :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: AssetContainerSas, or the result of cls(response) + :return: AssetContainerSas or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetContainerSas - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def list_container_sas( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AssetContainerSas: + """List the Asset URLs. + + Lists storage container URLs with shared access signatures (SAS) for uploading and downloading + Asset content. The signatures are derived from the storage account keys. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AssetContainerSas or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetContainerSas + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_container_sas( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: Union[_models.ListContainerSasInput, IO], + **kwargs: Any + ) -> _models.AssetContainerSas: + """List the Asset URLs. + + Lists storage container URLs with shared access signatures (SAS) for uploading and downloading + Asset content. The signatures are derived from the storage account keys. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ListContainerSasInput 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: AssetContainerSas or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetContainerSas + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetContainerSas] + 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.AssetContainerSas] - _json = self._serialize.body(parameters, 'ListContainerSasInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ListContainerSasInput") request = build_list_container_sas_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_container_sas.metadata['url'], + content=_content, + template_url=self.list_container_sas.metadata["url"], headers=_headers, params=_params, ) @@ -504,10 +709,9 @@ async def list_container_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -515,23 +719,18 @@ async def list_container_sas( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetContainerSas', pipeline_response) + deserialized = self._deserialize("AssetContainerSas", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_container_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas"} # type: ignore - + list_container_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas"} # type: ignore @distributed_trace_async async def get_encryption_key( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any ) -> _models.StorageEncryptedAssetDecryptionData: """Gets the Asset storage key. @@ -539,35 +738,33 @@ async def get_encryption_key( Media Services API. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageEncryptedAssetDecryptionData, or the result of cls(response) + :return: StorageEncryptedAssetDecryptionData or the result of cls(response) :rtype: ~azure.mgmt.media.models.StorageEncryptedAssetDecryptionData - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageEncryptedAssetDecryptionData] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageEncryptedAssetDecryptionData] - request = build_get_encryption_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_encryption_key.metadata['url'], + template_url=self.get_encryption_key.metadata["url"], headers=_headers, params=_params, ) @@ -575,10 +772,9 @@ async def get_encryption_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -586,58 +782,51 @@ async def get_encryption_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageEncryptedAssetDecryptionData', pipeline_response) + deserialized = self._deserialize("StorageEncryptedAssetDecryptionData", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_encryption_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey"} # type: ignore - + get_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey"} # type: ignore @distributed_trace_async async def list_streaming_locators( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any ) -> _models.ListStreamingLocatorsResponse: """List Streaming Locators. Lists Streaming Locators which are associated with this asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListStreamingLocatorsResponse, or the result of cls(response) + :return: ListStreamingLocatorsResponse or the result of cls(response) :rtype: ~azure.mgmt.media.models.ListStreamingLocatorsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListStreamingLocatorsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListStreamingLocatorsResponse] - request = build_list_streaming_locators_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_streaming_locators.metadata['url'], + template_url=self.list_streaming_locators.metadata["url"], headers=_headers, params=_params, ) @@ -645,10 +834,9 @@ async def list_streaming_locators( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,12 +844,11 @@ async def list_streaming_locators( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListStreamingLocatorsResponse', pipeline_response) + deserialized = self._deserialize("ListStreamingLocatorsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_streaming_locators.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators"} # type: ignore - + list_streaming_locators.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_content_key_policies_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_content_key_policies_operations.py index 6663b937a8c8..08311f3e01cb 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_content_key_policies_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_content_key_policies_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._content_key_policies_operations import build_create_or_update_request, build_delete_request, build_get_policy_properties_with_secrets_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._content_key_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_policy_properties_with_secrets_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ContentKeyPoliciesOperations: """ .. warning:: @@ -43,7 +58,6 @@ def __init__(self, *args, **kwargs) -> None: 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, @@ -53,14 +67,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ContentKeyPolicyCollection]: + ) -> AsyncIterable["_models.ContentKeyPolicy"]: """List Content Key Policies. Lists the Content Key Policies in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -72,34 +87,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContentKeyPolicyCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.ContentKeyPolicyCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.ContentKeyPolicy] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicyCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentKeyPolicyCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,19 +119,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -135,10 +135,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,54 +147,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, content_key_policy_name: str, **kwargs: Any ) -> _models.ContentKeyPolicy: """Get a Content Key Policy. Get the details of a Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentKeyPolicy, or the result of cls(response) + :return: ContentKeyPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentKeyPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -204,10 +194,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -215,23 +204,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, content_key_policy_name: str, parameters: _models.ContentKeyPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ContentKeyPolicy: """Create or update an Content Key Policy. @@ -239,41 +229,114 @@ async def create_or_update( Create or update a Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy + :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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Create or update an Content Key Policy. + + Create or update a Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: ContentKeyPolicy, or the result of cls(response) + :return: ContentKeyPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: Union[_models.ContentKeyPolicy, IO], + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Create or update an Content Key Policy. + + Create or update a Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy 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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicy] + 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.ContentKeyPolicy] - _json = self._serialize.body(parameters, 'ContentKeyPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ContentKeyPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -281,10 +344,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -293,61 +355,54 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, content_key_policy_name: str, **kwargs: Any ) -> None: """Delete a Content Key Policy. Deletes a Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -355,10 +410,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -369,16 +423,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, content_key_policy_name: str, parameters: _models.ContentKeyPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ContentKeyPolicy: """Update a Content Key Policy. @@ -386,41 +441,114 @@ async def update( Updates an existing Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy + :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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Update a Content Key Policy. + + Updates an existing Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: ContentKeyPolicy, or the result of cls(response) + :return: ContentKeyPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: Union[_models.ContentKeyPolicy, IO], + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Update a Content Key Policy. + + Updates an existing Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy 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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicy] + 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.ContentKeyPolicy] - _json = self._serialize.body(parameters, 'ContentKeyPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ContentKeyPolicy") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -428,10 +556,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -439,58 +566,51 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore @distributed_trace_async async def get_policy_properties_with_secrets( - self, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, content_key_policy_name: str, **kwargs: Any ) -> _models.ContentKeyPolicyProperties: """Get a Content Key Policy with secrets. Get a Content Key Policy including secret values. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentKeyPolicyProperties, or the result of cls(response) + :return: ContentKeyPolicyProperties or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicyProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicyProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentKeyPolicyProperties] - request = build_get_policy_properties_with_secrets_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_policy_properties_with_secrets.metadata['url'], + template_url=self.get_policy_properties_with_secrets.metadata["url"], headers=_headers, params=_params, ) @@ -498,10 +618,9 @@ async def get_policy_properties_with_secrets( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -509,12 +628,11 @@ async def get_policy_properties_with_secrets( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContentKeyPolicyProperties', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicyProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_policy_properties_with_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}/getPolicyPropertiesWithSecrets"} # type: ignore - + get_policy_properties_with_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}/getPolicyPropertiesWithSecrets"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_jobs_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_jobs_operations.py index afe4fe6b6088..816f28a12588 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_jobs_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_jobs_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._jobs_operations import build_cancel_job_request, build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._jobs_operations import ( + build_cancel_job_request, + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class JobsOperations: """ .. warning:: @@ -43,7 +58,6 @@ def __init__(self, *args, **kwargs) -> None: 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, @@ -53,16 +67,17 @@ def list( filter: Optional[str] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.JobCollection]: + ) -> AsyncIterable["_models.Job"]: """List Jobs. Lists all of the Jobs for the Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -70,32 +85,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.JobCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Job or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.Job] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JobCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -103,19 +117,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - transform_name=transform_name, - api_version=api_version, - filter=filter, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +133,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,58 +145,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, job_name: str, **kwargs: Any ) -> _models.Job: """Get Job. Gets a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.media.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Job] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -204,10 +195,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -215,17 +205,16 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, @@ -233,6 +222,8 @@ async def create( transform_name: str, job_name: str, parameters: _models.Job, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Job: """Create Job. @@ -240,44 +231,123 @@ async def create( Creates a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Job + :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: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.media.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Create Job. + + Creates a Job. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: Union[_models.Job, IO], + **kwargs: Any + ) -> _models.Job: + """Create Job. + + Creates a Job. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Job 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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + 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.Job] - _json = self._serialize.body(parameters, 'Job') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Job") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -285,10 +355,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -296,62 +365,54 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, job_name: str, **kwargs: Any ) -> None: """Delete Job. Deletes a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -359,10 +420,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -373,10 +433,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, @@ -384,6 +443,8 @@ async def update( transform_name: str, job_name: str, parameters: _models.Job, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Job: """Update Job. @@ -393,44 +454,127 @@ async def update( ignored. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Job + :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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Update Job. + + Update is only supported for description and priority. Updating Priority will take effect when + the Job state is Queued or Scheduled and depending on the timing the priority update may be + ignored. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.media.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: Union[_models.Job, IO], + **kwargs: Any + ) -> _models.Job: + """Update Job. + + Update is only supported for description and priority. Updating Priority will take effect when + the Job state is Queued or Scheduled and depending on the timing the priority update may be + ignored. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Job 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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + 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.Job] - _json = self._serialize.body(parameters, 'Job') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Job") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +582,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,62 +592,54 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore @distributed_trace_async async def cancel_job( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, job_name: str, **kwargs: Any ) -> None: """Cancel Job. Cancel a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_cancel_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_job.metadata['url'], + template_url=self.cancel_job.metadata["url"], headers=_headers, params=_params, ) @@ -512,10 +647,9 @@ async def cancel_job( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -526,5 +660,4 @@ async def cancel_job( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob"} # type: ignore - + cancel_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_events_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_events_operations.py index 6c796f180150..3c0c4bde45b2 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_events_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_events_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +28,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._live_events_operations import build_allocate_request_initial, build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_reset_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._live_events_operations import ( + build_allocate_request, + build_async_operation_request, + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_operation_location_request, + build_reset_request, + build_start_request, + build_stop_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LiveEventsOperations: """ .. warning:: @@ -45,46 +65,40 @@ def __init__(self, *args, **kwargs) -> None: 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 - ) -> AsyncIterable[_models.LiveEventListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.LiveEvent"]: """List live events. Lists all the live events in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. 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 LiveEventListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.LiveEventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LiveEvent or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.LiveEvent] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEventListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveEventListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +106,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,54 +134,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> _models.LiveEvent: """Get Live Event. Gets properties of a live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LiveEvent, or the result of cls(response) + :return: LiveEvent or the result of cls(response) :rtype: ~azure.mgmt.media.models.LiveEvent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveEvent] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -186,10 +181,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -197,49 +191,53 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, live_event_name: str, - parameters: _models.LiveEvent, + parameters: Union[_models.LiveEvent, IO], auto_start: Optional[bool] = None, **kwargs: Any ) -> _models.LiveEvent: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] + 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.LiveEvent] - _json = self._serialize.body(parameters, 'LiveEvent') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveEvent") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, + auto_start=auto_start, api_version=api_version, content_type=content_type, json=_json, - auto_start=auto_start, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -247,31 +245,30 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, @@ -279,6 +276,8 @@ async def begin_create( live_event_name: str, parameters: _models.LiveEvent, auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LiveEvent]: """Create Live Event. @@ -286,16 +285,109 @@ async def begin_create( Creates a new live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param parameters: Live event properties needed for creation. + :param parameters: Live event properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.LiveEvent :param auto_start: The flag indicates if the resource should be automatically started on creation. Default value is None. :type auto_start: bool + :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 LiveEvent or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: IO, + auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LiveEvent]: + """Create Live Event. + + Creates a new live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for creation. Required. + :type parameters: IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 LiveEvent or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: Union[_models.LiveEvent, IO], + auto_start: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.LiveEvent]: + """Create Live Event. + + Creates a new live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for creation. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.media.models.LiveEvent or IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 @@ -307,20 +399,17 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either LiveEvent or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveEvent] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.LiveEvent] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -330,71 +419,72 @@ async def begin_create( auto_start=auto_start, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore async def _update_initial( self, resource_group_name: str, account_name: str, live_event_name: str, - parameters: _models.LiveEvent, + parameters: Union[_models.LiveEvent, IO], **kwargs: Any ) -> _models.LiveEvent: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] + 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.LiveEvent] - _json = self._serialize.body(parameters, 'LiveEvent') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveEvent") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -402,49 +492,131 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, account_name: str, live_event_name: str, parameters: _models.LiveEvent, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LiveEvent]: """Updates settings on an existing live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param parameters: Live event properties needed for patch. + :param parameters: Live event properties needed for patch. Required. :type parameters: ~azure.mgmt.media.models.LiveEvent + :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 LiveEvent or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LiveEvent]: + """Updates settings on an existing live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for patch. Required. + :type parameters: 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 LiveEvent or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: Union[_models.LiveEvent, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LiveEvent]: + """Updates settings on an existing live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for patch. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.media.models.LiveEvent 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 @@ -456,20 +628,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either LiveEvent or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveEvent] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.LiveEvent] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -478,66 +647,55 @@ async def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -545,39 +703,35 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete Live Event. Deletes a live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -589,83 +743,69 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore async def _allocate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_allocate_request_initial( - subscription_id=self._config.subscription_id, + request = build_allocate_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._allocate_initial.metadata['url'], + template_url=self._allocate_initial.metadata["url"], headers=_headers, params=_params, ) @@ -673,39 +813,35 @@ async def _allocate_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _allocate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore - + _allocate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore @distributed_trace_async - async def begin_allocate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + async def begin_allocate( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Allocate resources for a live event. A live event is in StandBy state after allocation completes, and is ready to start. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -717,83 +853,69 @@ async def begin_allocate( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._allocate_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_allocate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore + begin_allocate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -801,29 +923,24 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start Live Event. @@ -831,10 +948,11 @@ async def begin_start( # pylint: disable=inconsistent-return-statements completes. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -846,88 +964,86 @@ async def begin_start( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, live_event_name: str, - parameters: _models.LiveEventActionInput, + parameters: Union[_models.LiveEventActionInput, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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[None] - _json = self._serialize.body(parameters, 'LiveEventActionInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveEventActionInput") - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + request = build_stop_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._stop_initial.metadata['url'], + content=_content, + template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) @@ -935,29 +1051,30 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore - @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements + @overload + async def begin_stop( self, resource_group_name: str, account_name: str, live_event_name: str, parameters: _models.LiveEventActionInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Stop Live Event. @@ -965,13 +1082,95 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Stops a running live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param parameters: LiveEvent stop parameters. + :param parameters: LiveEvent stop parameters. Required. :type parameters: ~azure.mgmt.media.models.LiveEventActionInput + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_stop( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Stop Live Event. + + Stops a running live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: LiveEvent stop parameters. Required. + :type parameters: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_stop( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: Union[_models.LiveEventActionInput, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Stop Live Event. + + Stops a running live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: LiveEvent stop parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.LiveEventActionInput 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 @@ -982,20 +1181,17 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, @@ -1004,64 +1200,53 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore async def _reset_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_reset_request_initial( - subscription_id=self._config.subscription_id, + request = build_reset_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._reset_initial.metadata['url'], + template_url=self._reset_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1069,29 +1254,24 @@ async def _reset_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _reset_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore - + _reset_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore @distributed_trace_async - async def begin_reset( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + async def begin_reset( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Reset Live Event. @@ -1100,10 +1280,11 @@ async def begin_reset( # pylint: disable=inconsistent-return-statements locators created on these assets are unaffected. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -1115,53 +1296,175 @@ async def begin_reset( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._reset_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_reset.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore + begin_reset.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore + + @distributed_trace_async + async def async_operation( + self, resource_group_name: str, account_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: + """Get operation status. + + Get a live event operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AsyncOperationResult or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AsyncOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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.AsyncOperationResult] + + request = build_async_operation_request( + resource_group_name=resource_group_name, + account_name=account_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.async_operation.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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("AsyncOperationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEventOperations/{operationId}"} # type: ignore + + @distributed_trace_async + async def operation_location( + self, resource_group_name: str, account_name: str, live_event_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.LiveEvent]: + """Get operation status. + + Get a live event operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LiveEvent or None or the result of cls(response) + :rtype: ~azure.mgmt.media.models.LiveEvent or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[Optional[_models.LiveEvent]] + + request = build_operation_location_request( + resource_group_name=resource_group_name, + account_name=account_name, + live_event_name=live_event_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.operation_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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 + if response.status_code == 200: + deserialized = self._deserialize("LiveEvent", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + operation_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/operationLocations/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_outputs_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_outputs_operations.py index 6eb8785490fa..5e6d5821942b 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_outputs_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_live_outputs_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +28,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._live_outputs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._live_outputs_operations import ( + build_async_operation_request, + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_operation_location_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LiveOutputsOperations: """ .. warning:: @@ -45,51 +60,45 @@ def __init__(self, *args, **kwargs) -> None: 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, - live_event_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.LiveOutputListResult]: + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LiveOutput"]: """List Live Outputs. Lists the live outputs of a live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LiveOutputListResult or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.LiveOutputListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LiveOutput or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.LiveOutput] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutputListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveOutputListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -97,17 +106,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - live_event_name=live_event_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -123,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,58 +134,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - live_output_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, **kwargs: Any ) -> _models.LiveOutput: """Get Live Output. Gets a live output. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param live_output_name: The name of the live output. + :param live_output_name: The name of the live output. Required. :type live_output_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LiveOutput, or the result of cls(response) + :return: LiveOutput or the result of cls(response) :rtype: ~azure.mgmt.media.models.LiveOutput - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutput] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveOutput] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, live_output_name=live_output_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -196,10 +184,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,15 +194,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore async def _create_initial( self, @@ -223,33 +209,38 @@ async def _create_initial( account_name: str, live_event_name: str, live_output_name: str, - parameters: _models.LiveOutput, + parameters: Union[_models.LiveOutput, IO], **kwargs: Any ) -> _models.LiveOutput: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutput] + 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.LiveOutput] - _json = self._serialize.body(parameters, 'LiveOutput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveOutput") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, live_output_name=live_output_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -257,31 +248,30 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, @@ -289,6 +279,8 @@ async def begin_create( live_event_name: str, live_output_name: str, parameters: _models.LiveOutput, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LiveOutput]: """Create Live Output. @@ -296,15 +288,19 @@ async def begin_create( Creates a new live output. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param live_output_name: The name of the live output. + :param live_output_name: The name of the live output. Required. :type live_output_name: str - :param parameters: Live Output properties needed for creation. + :param parameters: Live Output properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.LiveOutput + :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 @@ -316,20 +312,104 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either LiveOutput or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveOutput] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + live_output_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LiveOutput]: + """Create Live Output. + + Creates a new live output. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param live_output_name: The name of the live output. Required. + :type live_output_name: str + :param parameters: Live Output properties needed for creation. Required. + :type parameters: 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 LiveOutput or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + live_output_name: str, + parameters: Union[_models.LiveOutput, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LiveOutput]: + """Create Live Output. + + Creates a new live output. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param live_output_name: The name of the live output. Required. + :type live_output_name: str + :param parameters: Live Output properties needed for creation. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.media.models.LiveOutput 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 LiveOutput or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.LiveOutput] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutput] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.LiveOutput] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -339,68 +419,56 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - live_output_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, live_output_name=live_output_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -408,30 +476,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - live_output_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete Live Output. @@ -439,12 +501,13 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements writing to. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param live_output_name: The name of the live output. + :param live_output_name: The name of the live output. Required. :type live_output_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. @@ -456,19 +519,16 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -476,34 +536,168 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements live_event_name=live_event_name, live_output_name=live_output_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + + @distributed_trace_async + async def async_operation( + self, resource_group_name: str, account_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: + """Get operation status. + + Get a Live Output operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AsyncOperationResult or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AsyncOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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.AsyncOperationResult] + + request = build_async_operation_request( + resource_group_name=resource_group_name, + account_name=account_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.async_operation.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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("AsyncOperationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveOutputOperations/{operationId}"} # type: ignore + + @distributed_trace_async + async def operation_location( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + live_output_name: str, + operation_id: str, + **kwargs: Any + ) -> Optional[_models.LiveOutput]: + """Get operation status. + + Get a Live Output operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param live_output_name: The name of the live output. Required. + :type live_output_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LiveOutput or None or the result of cls(response) + :rtype: ~azure.mgmt.media.models.LiveOutput or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[Optional[_models.LiveOutput]] + + request = build_operation_location_request( + resource_group_name=resource_group_name, + account_name=account_name, + live_event_name=live_event_name, + live_output_name=live_output_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.operation_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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 + if response.status_code == 200: + deserialized = self._deserialize("LiveOutput", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + operation_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}/operationLocations/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_locations_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_locations_operations.py index 12a438a7e35b..368ff1cc6e6a 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_locations_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_locations_operations.py @@ -6,9 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._locations_operations import build_check_name_availability_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LocationsOperations: """ .. warning:: @@ -41,48 +49,99 @@ def __init__(self, *args, **kwargs) -> None: 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_async + @overload async def check_name_availability( self, location_name: str, parameters: _models.CheckNameAvailabilityInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EntityNameAvailabilityCheckOutput: """Check Name Availability. Checks whether the Media Service resource name is available. - :param location_name: Location name. + :param location_name: Location name. Required. :type location_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.CheckNameAvailabilityInput + :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: EntityNameAvailabilityCheckOutput or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EntityNameAvailabilityCheckOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EntityNameAvailabilityCheckOutput: + """Check Name Availability. + + Checks whether the Media Service resource name is available. + + :param location_name: Location name. Required. + :type location_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: EntityNameAvailabilityCheckOutput, or the result of cls(response) + :return: EntityNameAvailabilityCheckOutput or the result of cls(response) :rtype: ~azure.mgmt.media.models.EntityNameAvailabilityCheckOutput - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def check_name_availability( + self, location_name: str, parameters: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + ) -> _models.EntityNameAvailabilityCheckOutput: + """Check Name Availability. + + Checks whether the Media Service resource name is available. + + :param location_name: Location name. Required. + :type location_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.CheckNameAvailabilityInput 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: EntityNameAvailabilityCheckOutput or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EntityNameAvailabilityCheckOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EntityNameAvailabilityCheckOutput] + 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.EntityNameAvailabilityCheckOutput] - _json = self._serialize.body(parameters, 'CheckNameAvailabilityInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailabilityInput") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location_name=location_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -90,10 +149,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +159,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EntityNameAvailabilityCheckOutput', pipeline_response) + deserialized = self._deserialize("EntityNameAvailabilityCheckOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_results_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_results_operations.py index 5c6f6bf3efc9..0372864cb387 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_results_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_results_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._media_services_operation_results_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MediaServicesOperationResultsOperations: """ .. warning:: @@ -41,45 +49,36 @@ def __init__(self, *args, **kwargs) -> None: 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_async - async def get( - self, - location_name: str, - operation_id: str, - **kwargs: Any - ) -> Optional[_models.MediaService]: + async def get(self, location_name: str, operation_id: str, **kwargs: Any) -> Optional[_models.MediaService]: """Get operation result. Get media service operation result. - :param location_name: Location name. + :param location_name: Location name. Required. :type location_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MediaService, or the result of cls(response) + :return: MediaService or None or the result of cls(response) :rtype: ~azure.mgmt.media.models.MediaService or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MediaService]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MediaService]] - request = build_get_request( - subscription_id=self._config.subscription_id, location_name=location_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -87,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -101,18 +99,18 @@ async def get( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('MediaService', pipeline_response) + deserialized = self._deserialize("MediaService", pipeline_response) if response.status_code == 202: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationResults/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationResults/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_statuses_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_statuses_operations.py index fb4a2ddc91f1..827a3d5fcc5d 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_statuses_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_media_services_operation_statuses_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._media_services_operation_statuses_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MediaServicesOperationStatusesOperations: """ .. warning:: @@ -41,45 +49,36 @@ def __init__(self, *args, **kwargs) -> None: 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_async - async def get( - self, - location_name: str, - operation_id: str, - **kwargs: Any - ) -> _models.MediaServiceOperationStatus: + async def get(self, location_name: str, operation_id: str, **kwargs: Any) -> _models.MediaServiceOperationStatus: """Get operation status. Get media service operation status. - :param location_name: Location name. + :param location_name: Location name. Required. :type location_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MediaServiceOperationStatus, or the result of cls(response) + :return: MediaServiceOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.media.models.MediaServiceOperationStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaServiceOperationStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaServiceOperationStatus] - request = build_get_request( - subscription_id=self._config.subscription_id, location_name=location_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -87,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,12 +96,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MediaServiceOperationStatus', pipeline_response) + deserialized = self._deserialize("MediaServiceOperationStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationStatuses/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationStatuses/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_mediaservices_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_mediaservices_operations.py index ee34a59c2197..de2ce4bc175c 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_mediaservices_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_mediaservices_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +28,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._mediaservices_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_subscription_request, build_list_edge_policies_request, build_list_request, build_sync_storage_keys_request, build_update_request_initial -T = TypeVar('T') +from ...operations._mediaservices_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscription_request, + build_list_edge_policies_request, + build_list_request, + build_sync_storage_keys_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MediaservicesOperations: """ .. warning:: @@ -45,44 +62,37 @@ def __init__(self, *args, **kwargs) -> None: 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, - **kwargs: Any - ) -> AsyncIterable[_models.MediaServiceCollection]: + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.MediaService"]: """List Media Services accounts. List Media Services accounts in the resource group. :param resource_group_name: The name of the resource group within the Azure subscription. + 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 MediaServiceCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.MediaServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MediaService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.MediaService] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaServiceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaServiceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -90,15 +100,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -114,10 +116,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,50 +128,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.MediaService: + async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.MediaService: """Get a Media Services account. Get the details of a Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MediaService, or the result of cls(response) + :return: MediaService or the result of cls(response) :rtype: ~azure.mgmt.media.models.MediaService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaService] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -179,10 +170,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,45 +180,45 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MediaService', pipeline_response) + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - account_name: str, - parameters: _models.MediaService, - **kwargs: Any + self, resource_group_name: str, account_name: str, parameters: Union[_models.MediaService, IO], **kwargs: Any ) -> _models.MediaService: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] + 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.MediaService] - _json = self._serialize.body(parameters, 'MediaService') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MediaService") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -236,45 +226,50 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if response.status_code == 201: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, account_name: str, parameters: _models.MediaService, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MediaService]: """Create or update a Media Services account. @@ -282,11 +277,85 @@ async def begin_create_or_update( Creates or updates a Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.MediaService + :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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MediaService]: + """Create or update a Media Services account. + + Creates or updates a Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, account_name: str, parameters: Union[_models.MediaService, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.MediaService]: + """Create or update a Media Services account. + + Creates or updates a Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.MediaService 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 @@ -298,20 +367,17 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either MediaService or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.MediaService] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.MediaService] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -319,84 +385,77 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Delete a Media Services account. Deletes a Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -404,10 +463,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -418,38 +476,42 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore async def _update_initial( self, resource_group_name: str, account_name: str, - parameters: _models.MediaServiceUpdate, + parameters: Union[_models.MediaServiceUpdate, IO], **kwargs: Any ) -> _models.MediaService: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] + 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.MediaService] - _json = self._serialize.body(parameters, 'MediaServiceUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MediaServiceUpdate") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -457,37 +519,40 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize('MediaService', pipeline_response) + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, account_name: str, parameters: _models.MediaServiceUpdate, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MediaService]: """Update a Media Services account. @@ -495,11 +560,89 @@ async def begin_update( Updates an existing Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.MediaServiceUpdate + :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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MediaService]: + """Update a Media Services account. + + Updates an existing Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.MediaServiceUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MediaService]: + """Update a Media Services account. + + Updates an existing Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.MediaServiceUpdate 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 @@ -511,20 +654,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either MediaService or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.MediaService] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.MediaService] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -532,52 +672,52 @@ async def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def sync_storage_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, parameters: _models.SyncStorageKeysInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Synchronizes Storage Account Keys. @@ -586,38 +726,107 @@ async def sync_storage_keys( # pylint: disable=inconsistent-return-statements account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.SyncStorageKeysInput + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def sync_storage_keys( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Synchronizes Storage Account Keys. + + Synchronizes storage account keys for a storage account associated with the Media Service + account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def sync_storage_keys( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.SyncStorageKeysInput, IO], + **kwargs: Any + ) -> None: + """Synchronizes Storage Account Keys. + + Synchronizes storage account keys for a storage account associated with the Media Service + account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.SyncStorageKeysInput 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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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[None] - _json = self._serialize.body(parameters, 'SyncStorageKeysInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncStorageKeysInput") request = build_sync_storage_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sync_storage_keys.metadata['url'], + content=_content, + template_url=self.sync_storage_keys.metadata["url"], headers=_headers, params=_params, ) @@ -625,10 +834,9 @@ async def sync_storage_keys( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -639,15 +847,16 @@ async def sync_storage_keys( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - sync_storage_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/syncStorageKeys"} # type: ignore + sync_storage_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/syncStorageKeys"} # type: ignore - - @distributed_trace_async + @overload async def list_edge_policies( self, resource_group_name: str, account_name: str, parameters: _models.ListEdgePoliciesInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EdgePolicies: """List the media edge policies associated with the Media Services account. @@ -655,38 +864,105 @@ async def list_edge_policies( List all the media edge policies associated with the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ListEdgePoliciesInput + :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: EdgePolicies or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EdgePolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_edge_policies( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EdgePolicies: + """List the media edge policies associated with the Media Services account. + + List all the media edge policies associated with the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: EdgePolicies, or the result of cls(response) + :return: EdgePolicies or the result of cls(response) :rtype: ~azure.mgmt.media.models.EdgePolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def list_edge_policies( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ListEdgePoliciesInput, IO], + **kwargs: Any + ) -> _models.EdgePolicies: + """List the media edge policies associated with the Media Services account. + + List all the media edge policies associated with the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ListEdgePoliciesInput 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: EdgePolicies or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EdgePolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EdgePolicies] + 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.EdgePolicies] - _json = self._serialize.body(parameters, 'ListEdgePoliciesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ListEdgePoliciesInput") request = build_list_edge_policies_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_edge_policies.metadata['url'], + content=_content, + template_url=self.list_edge_policies.metadata["url"], headers=_headers, params=_params, ) @@ -694,10 +970,9 @@ async def list_edge_policies( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -705,49 +980,42 @@ async def list_edge_policies( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EdgePolicies', pipeline_response) + deserialized = self._deserialize("EdgePolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_edge_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/listEdgePolicies"} # type: ignore - + list_edge_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/listEdgePolicies"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.MediaServiceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.MediaService"]: """List Media Services accounts. List Media Services accounts in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MediaServiceCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.MediaServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MediaService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.MediaService] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaServiceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaServiceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -755,14 +1023,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -778,10 +1039,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,8 +1051,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/mediaservices"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/mediaservices"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_results_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_results_operations.py index c4803588b0ca..edf480696e8c 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_results_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_results_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operation_results_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class OperationResultsOperations: """ .. warning:: @@ -41,7 +49,6 @@ def __init__(self, *args, **kwargs) -> None: 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_async async def get( self, @@ -57,41 +64,39 @@ async def get( Get asset track operation result. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetTrack, or the result of cls(response) + :return: AssetTrack or None or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetTrack or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AssetTrack]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AssetTrack]] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -99,10 +104,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -113,18 +117,18 @@ async def get( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('AssetTrack', pipeline_response) + deserialized = self._deserialize("AssetTrack", pipeline_response) if response.status_code == 202: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationResults/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_statuses_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_statuses_operations.py index 2f789dc7ac48..8cfd2a275d76 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_statuses_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operation_statuses_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operation_statuses_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class OperationStatusesOperations: """ .. warning:: @@ -41,7 +49,6 @@ def __init__(self, *args, **kwargs) -> None: 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_async async def get( self, @@ -57,41 +64,39 @@ async def get( Get asset track operation status. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetTrackOperationStatus, or the result of cls(response) + :return: AssetTrackOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetTrackOperationStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrackOperationStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetTrackOperationStatus] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -99,10 +104,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,12 +114,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetTrackOperationStatus', pipeline_response) + deserialized = self._deserialize("AssetTrackOperationStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operations.py index 3c093c8bb057..3fd649d947b2 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -41,36 +49,29 @@ def __init__(self, *args, **kwargs) -> None: 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_async - async def list( - self, - **kwargs: Any - ) -> _models.OperationCollection: + async def list(self, **kwargs: Any) -> _models.OperationCollection: """List Operations. Lists all the Media Services operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationCollection, or the result of cls(response) + :return: OperationCollection or the result of cls(response) :rtype: ~azure.mgmt.media.models.OperationCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationCollection] - request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -78,10 +79,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -89,12 +89,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationCollection', pipeline_response) + deserialized = self._deserialize("OperationCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Media/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Media/operations"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_patch.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_patch.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_endpoint_connections_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_endpoint_connections_operations.py index 3ee1f3542715..70547b595c34 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_endpoint_connections_operations.py @@ -6,9 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +24,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -41,45 +54,39 @@ def __init__(self, *args, **kwargs) -> None: 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_async async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnectionListResult: """List private endpoint connections. List all private endpoint connections. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionListResult, or the result of cls(response) + :return: PrivateEndpointConnectionListResult or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateEndpointConnectionListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + 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] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -87,10 +94,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,58 +104,51 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get the details of a private endpoint connection. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + 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] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -157,10 +156,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -168,23 +166,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update a private endpoint connection. @@ -192,41 +191,114 @@ async def create_or_update( Update an existing private endpoint connection. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update a private endpoint connection. + + Update an existing private endpoint connection. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param name: Required. + :type name: str + :param parameters: The request parameters. Required. + :type parameters: 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update a private endpoint connection. + + Update an existing private endpoint connection. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param name: Required. + :type name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.PrivateEndpointConnection 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + 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] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -234,10 +306,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,58 +316,51 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, name: str, **kwargs: Any ) -> None: """Delete a private endpoint connection. Deletes a private endpoint connection. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +368,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -318,5 +381,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_link_resources_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_link_resources_operations.py index 5c1b55067ef5..a83947559e40 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_link_resources_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_private_link_resources_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,45 +49,39 @@ def __init__(self, *args, **kwargs) -> None: 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_async async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Get list of group IDs. List supported group IDs. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + 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] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -87,10 +89,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,58 +99,51 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, name: str, **kwargs: Any ) -> _models.PrivateLinkResource: """Get group ID. Get details of a group ID. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -157,10 +151,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -168,12 +161,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_endpoints_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_endpoints_operations.py index f50d94994ce3..41d0da6c4694 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_endpoints_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_endpoints_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +28,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._streaming_endpoints_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_scale_request_initial, build_skus_request, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._streaming_endpoints_operations import ( + build_async_operation_request, + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_operation_location_request, + build_scale_request, + build_skus_request, + build_start_request, + build_stop_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StreamingEndpointsOperations: """ .. warning:: @@ -45,48 +65,42 @@ def __init__(self, *args, **kwargs) -> None: 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 - ) -> AsyncIterable[_models.StreamingEndpointListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StreamingEndpoint"]: """List StreamingEndpoints. Lists the streaming endpoints in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. 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 StreamingEndpointListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.StreamingEndpointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StreamingEndpoint or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.StreamingEndpoint] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpointListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingEndpointListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -94,16 +108,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -119,10 +124,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,54 +136,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> _models.StreamingEndpoint: """Get StreamingEndpoint. Gets a streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingEndpoint, or the result of cls(response) + :return: StreamingEndpoint or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingEndpoint - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingEndpoint] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +184,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,49 +194,53 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, - parameters: _models.StreamingEndpoint, + parameters: Union[_models.StreamingEndpoint, IO], auto_start: Optional[bool] = None, **kwargs: Any ) -> _models.StreamingEndpoint: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] + 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.StreamingEndpoint] - _json = self._serialize.body(parameters, 'StreamingEndpoint') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingEndpoint") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, + auto_start=auto_start, api_version=api_version, content_type=content_type, json=_json, - auto_start=auto_start, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -249,31 +248,30 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, @@ -281,6 +279,8 @@ async def begin_create( streaming_endpoint_name: str, parameters: _models.StreamingEndpoint, auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StreamingEndpoint]: """Create StreamingEndpoint. @@ -288,16 +288,67 @@ async def begin_create( Creates a streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str - :param parameters: Streaming endpoint properties needed for creation. + :param parameters: Streaming endpoint properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.StreamingEndpoint :param auto_start: The flag indicates if the resource should be automatically started on creation. Default value is None. :type auto_start: bool + :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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: IO, + auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StreamingEndpoint]: + """Create StreamingEndpoint. + + Creates a streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Required. + :type parameters: IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 @@ -309,20 +360,62 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either StreamingEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.StreamingEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: Union[_models.StreamingEndpoint, IO], + auto_start: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.StreamingEndpoint]: + """Create StreamingEndpoint. + + Creates a streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingEndpoint or IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.StreamingEndpoint] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -332,71 +425,72 @@ async def begin_create( auto_start=auto_start, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore async def _update_initial( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, - parameters: _models.StreamingEndpoint, + parameters: Union[_models.StreamingEndpoint, IO], **kwargs: Any ) -> _models.StreamingEndpoint: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] + 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.StreamingEndpoint] - _json = self._serialize.body(parameters, 'StreamingEndpoint') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingEndpoint") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -404,37 +498,38 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, parameters: _models.StreamingEndpoint, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StreamingEndpoint]: """Update StreamingEndpoint. @@ -442,13 +537,18 @@ async def begin_update( Updates a existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str - :param parameters: Streaming endpoint properties needed for creation. + :param parameters: Streaming endpoint properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.StreamingEndpoint + :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 @@ -460,20 +560,100 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either StreamingEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.StreamingEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StreamingEndpoint]: + """Update StreamingEndpoint. + + Updates a existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Required. + :type parameters: 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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: Union[_models.StreamingEndpoint, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StreamingEndpoint]: + """Update StreamingEndpoint. + + Updates a existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingEndpoint 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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.StreamingEndpoint] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -482,66 +662,55 @@ async def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -549,39 +718,36 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete StreamingEndpoint. Deletes a streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_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. @@ -593,99 +759,87 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore @distributed_trace_async async def skus( - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> _models.StreamingEndpointSkuInfoListResult: """List StreamingEndpoint skus. List streaming endpoint supported skus. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingEndpointSkuInfoListResult, or the result of cls(response) + :return: StreamingEndpointSkuInfoListResult or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingEndpointSkuInfoListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpointSkuInfoListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingEndpointSkuInfoListResult] - request = build_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.skus.metadata['url'], + template_url=self.skus.metadata["url"], headers=_headers, params=_params, ) @@ -693,10 +847,9 @@ async def skus( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,42 +857,34 @@ async def skus( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingEndpointSkuInfoListResult', pipeline_response) + deserialized = self._deserialize("StreamingEndpointSkuInfoListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - skus.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus"} # type: ignore - + skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -747,39 +892,36 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Start StreamingEndpoint. Starts an existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_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. @@ -791,83 +933,69 @@ async def begin_start( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + request = build_stop_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) @@ -875,39 +1003,36 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop StreamingEndpoint. Stops an existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_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. @@ -919,88 +1044,86 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore async def _scale_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, - parameters: _models.StreamingEntityScaleUnit, + parameters: Union[_models.StreamingEntityScaleUnit, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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[None] - _json = self._serialize.body(parameters, 'StreamingEntityScaleUnit') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingEntityScaleUnit") - request = build_scale_request_initial( - subscription_id=self._config.subscription_id, + request = build_scale_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._scale_initial.metadata['url'], + content=_content, + template_url=self._scale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1008,29 +1131,30 @@ async def _scale_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _scale_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore - + _scale_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore - @distributed_trace_async - async def begin_scale( # pylint: disable=inconsistent-return-statements + @overload + async def begin_scale( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, parameters: _models.StreamingEntityScaleUnit, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Scale StreamingEndpoint. @@ -1038,13 +1162,99 @@ async def begin_scale( # pylint: disable=inconsistent-return-statements Scales an existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str - :param parameters: Streaming endpoint scale parameters. + :param parameters: Streaming endpoint scale parameters. Required. :type parameters: ~azure.mgmt.media.models.StreamingEntityScaleUnit + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_scale( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Scale StreamingEndpoint. + + Scales an existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint scale parameters. Required. + :type parameters: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_scale( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: Union[_models.StreamingEntityScaleUnit, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Scale StreamingEndpoint. + + Scales an existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint scale parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.media.models.StreamingEntityScaleUnit 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 @@ -1055,20 +1265,17 @@ async def begin_scale( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._scale_initial( # type: ignore resource_group_name=resource_group_name, @@ -1077,34 +1284,165 @@ async def begin_scale( # pylint: disable=inconsistent-return-statements parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scale.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore + begin_scale.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore + + @distributed_trace_async + async def async_operation( + self, resource_group_name: str, account_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: + """Get operation status. + + Get a streaming endpoint operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AsyncOperationResult or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AsyncOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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.AsyncOperationResult] + + request = build_async_operation_request( + resource_group_name=resource_group_name, + account_name=account_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.async_operation.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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("AsyncOperationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpointOperations/{operationId}"} # type: ignore + + @distributed_trace_async + async def operation_location( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + operation_id: str, + **kwargs: Any + ) -> Optional[_models.StreamingEndpoint]: + """Get operation status. + + Get a streaming endpoint operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StreamingEndpoint or None or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingEndpoint or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[Optional[_models.StreamingEndpoint]] + + request = build_operation_location_request( + resource_group_name=resource_group_name, + account_name=account_name, + streaming_endpoint_name=streaming_endpoint_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.operation_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # 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 + if response.status_code == 200: + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + operation_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/operationLocations/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_locators_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_locators_operations.py index 0bdf5afc18c8..c983989ba046 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_locators_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_locators_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._streaming_locators_operations import build_create_request, build_delete_request, build_get_request, build_list_content_keys_request, build_list_paths_request, build_list_request -T = TypeVar('T') +from ...operations._streaming_locators_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_content_keys_request, + build_list_paths_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StreamingLocatorsOperations: """ .. warning:: @@ -43,7 +58,6 @@ def __init__(self, *args, **kwargs) -> None: 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, @@ -53,14 +67,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.StreamingLocatorCollection]: + ) -> AsyncIterable["_models.StreamingLocator"]: """List Streaming Locators. Lists the Streaming Locators in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -72,34 +87,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StreamingLocatorCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.StreamingLocatorCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StreamingLocator or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.StreamingLocator] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingLocatorCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingLocatorCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,19 +119,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -135,10 +135,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,54 +147,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> _models.StreamingLocator: """Get a Streaming Locator. Get the details of a Streaming Locator in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingLocator, or the result of cls(response) + :return: StreamingLocator or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingLocator - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingLocator] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingLocator] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -204,10 +194,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -215,23 +204,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingLocator', pipeline_response) + deserialized = self._deserialize("StreamingLocator", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, streaming_locator_name: str, parameters: _models.StreamingLocator, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StreamingLocator: """Create a Streaming Locator. @@ -239,41 +229,114 @@ async def create( Create a Streaming Locator in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.StreamingLocator + :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: StreamingLocator or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingLocator + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + streaming_locator_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StreamingLocator: + """Create a Streaming Locator. + + Create a Streaming Locator in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_locator_name: The Streaming Locator name. Required. + :type streaming_locator_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: StreamingLocator or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingLocator + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + streaming_locator_name: str, + parameters: Union[_models.StreamingLocator, IO], + **kwargs: Any + ) -> _models.StreamingLocator: + """Create a Streaming Locator. + + Create a Streaming Locator in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_locator_name: The Streaming Locator name. Required. + :type streaming_locator_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingLocator 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: StreamingLocator, or the result of cls(response) + :return: StreamingLocator or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingLocator - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingLocator] + 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.StreamingLocator] - _json = self._serialize.body(parameters, 'StreamingLocator') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingLocator") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -281,10 +344,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -292,58 +354,51 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingLocator', pipeline_response) + deserialized = self._deserialize("StreamingLocator", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> None: """Delete a Streaming Locator. Deletes a Streaming Locator in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +406,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -365,51 +419,44 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore @distributed_trace_async async def list_content_keys( - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> _models.ListContentKeysResponse: """List Content Keys. List Content Keys used by this Streaming Locator. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContentKeysResponse, or the result of cls(response) + :return: ListContentKeysResponse or the result of cls(response) :rtype: ~azure.mgmt.media.models.ListContentKeysResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContentKeysResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContentKeysResponse] - request = build_list_content_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_content_keys.metadata['url'], + template_url=self.list_content_keys.metadata["url"], headers=_headers, params=_params, ) @@ -417,10 +464,9 @@ async def list_content_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -428,58 +474,51 @@ async def list_content_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContentKeysResponse', pipeline_response) + deserialized = self._deserialize("ListContentKeysResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_content_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys"} # type: ignore - + list_content_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys"} # type: ignore @distributed_trace_async async def list_paths( - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> _models.ListPathsResponse: """List Paths. List Paths supported by this Streaming Locator. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListPathsResponse, or the result of cls(response) + :return: ListPathsResponse or the result of cls(response) :rtype: ~azure.mgmt.media.models.ListPathsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPathsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListPathsResponse] - request = build_list_paths_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_paths.metadata['url'], + template_url=self.list_paths.metadata["url"], headers=_headers, params=_params, ) @@ -487,10 +526,9 @@ async def list_paths( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -498,12 +536,11 @@ async def list_paths( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListPathsResponse', pipeline_response) + deserialized = self._deserialize("ListPathsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_paths.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths"} # type: ignore - + list_paths.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_policies_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_policies_operations.py index c91b08d448c5..b97f97ad79fd 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_policies_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_streaming_policies_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._streaming_policies_operations import build_create_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._streaming_policies_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StreamingPoliciesOperations: """ .. warning:: @@ -43,7 +56,6 @@ def __init__(self, *args, **kwargs) -> None: 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, @@ -53,14 +65,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.StreamingPolicyCollection]: + ) -> AsyncIterable["_models.StreamingPolicy"]: """List Streaming Policies. Lists the Streaming Policies in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -72,34 +85,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StreamingPolicyCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.StreamingPolicyCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StreamingPolicy or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.StreamingPolicy] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingPolicyCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingPolicyCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,19 +117,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -135,10 +133,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,54 +145,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_policy_name: str, **kwargs: Any ) -> _models.StreamingPolicy: """Get a Streaming Policy. Get the details of a Streaming Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_policy_name: The Streaming Policy name. + :param streaming_policy_name: The Streaming Policy name. Required. :type streaming_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingPolicy, or the result of cls(response) + :return: StreamingPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_policy_name=streaming_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -204,10 +192,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -215,23 +202,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingPolicy', pipeline_response) + deserialized = self._deserialize("StreamingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, streaming_policy_name: str, parameters: _models.StreamingPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StreamingPolicy: """Create a Streaming Policy. @@ -239,41 +227,114 @@ async def create( Create a Streaming Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_policy_name: The Streaming Policy name. + :param streaming_policy_name: The Streaming Policy name. Required. :type streaming_policy_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.StreamingPolicy + :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: StreamingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + streaming_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StreamingPolicy: + """Create a Streaming Policy. + + Create a Streaming Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_policy_name: The Streaming Policy name. Required. + :type streaming_policy_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: StreamingPolicy, or the result of cls(response) + :return: StreamingPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + streaming_policy_name: str, + parameters: Union[_models.StreamingPolicy, IO], + **kwargs: Any + ) -> _models.StreamingPolicy: + """Create a Streaming Policy. + + Create a Streaming Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_policy_name: The Streaming Policy name. Required. + :type streaming_policy_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingPolicy 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: StreamingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingPolicy] + 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.StreamingPolicy] - _json = self._serialize.body(parameters, 'StreamingPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingPolicy") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_policy_name=streaming_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -281,10 +342,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -292,58 +352,51 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingPolicy', pipeline_response) + deserialized = self._deserialize("StreamingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_policy_name: str, **kwargs: Any ) -> None: """Delete a Streaming Policy. Deletes a Streaming Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_policy_name: The Streaming Policy name. + :param streaming_policy_name: The Streaming Policy name. Required. :type streaming_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_policy_name=streaming_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +404,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -365,5 +417,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_tracks_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_tracks_operations.py index 5f78e6a9992f..e980b6f6a812 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_tracks_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_tracks_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +28,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._tracks_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial, build_update_track_data_request_initial -T = TypeVar('T') +from ...operations._tracks_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, + build_update_track_data_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TracksOperations: """ .. warning:: @@ -45,51 +60,45 @@ def __init__(self, *args, **kwargs) -> None: 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, - asset_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AssetTrackCollection]: + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AssetTrack"]: """List Tracks in the Asset. Lists the Tracks in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AssetTrackCollection or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AssetTrackCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AssetTrack or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.AssetTrack] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrackCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetTrackCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -97,17 +106,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - asset_name=asset_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -123,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,58 +134,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> _models.AssetTrack: """Get a Track. Get the details of a Track in the Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetTrack, or the result of cls(response) + :return: AssetTrack or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetTrack - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetTrack] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -196,10 +184,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,15 +194,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetTrack', pipeline_response) + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore async def _create_or_update_initial( self, @@ -223,33 +209,38 @@ async def _create_or_update_initial( account_name: str, asset_name: str, track_name: str, - parameters: _models.AssetTrack, + parameters: Union[_models.AssetTrack, IO], **kwargs: Any ) -> _models.AssetTrack: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] + 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.AssetTrack] - _json = self._serialize.body(parameters, 'AssetTrack') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetTrack") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -257,40 +248,43 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if response.status_code == 201: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -298,6 +292,8 @@ async def begin_create_or_update( asset_name: str, track_name: str, parameters: _models.AssetTrack, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AssetTrack]: """Create or update a Track. @@ -305,15 +301,19 @@ async def begin_create_or_update( Create or update a Track in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetTrack + :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 @@ -325,20 +325,103 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either AssetTrack or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.AssetTrack] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetTrack]: + """Create or update a Track. + + Create or update a Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 AssetTrack or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: Union[_models.AssetTrack, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetTrack]: + """Create or update a Track. + + Create or update a Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetTrack 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 AssetTrack or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.AssetTrack] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -348,74 +431,64 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -423,49 +496,45 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, None, response_headers) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a Track. Deletes a Track in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_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. @@ -477,19 +546,16 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -497,37 +563,33 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asset_name=asset_name, track_name=track_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore async def _update_initial( self, @@ -535,33 +597,38 @@ async def _update_initial( account_name: str, asset_name: str, track_name: str, - parameters: _models.AssetTrack, + parameters: Union[_models.AssetTrack, IO], **kwargs: Any ) -> _models.AssetTrack: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] + 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.AssetTrack] - _json = self._serialize.body(parameters, 'AssetTrack') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetTrack") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -569,32 +636,33 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize('AssetTrack', pipeline_response) + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, @@ -602,6 +670,8 @@ async def begin_update( asset_name: str, track_name: str, parameters: _models.AssetTrack, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AssetTrack]: """Update an Track. @@ -609,15 +679,105 @@ async def begin_update( Updates an existing Track in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetTrack + :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 AssetTrack or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetTrack]: + """Update an Track. + + Updates an existing Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 AssetTrack or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: Union[_models.AssetTrack, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetTrack]: + """Update an Track. + + Updates an existing Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetTrack 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 @@ -629,20 +789,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either AssetTrack or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.media.models.AssetTrack] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.AssetTrack] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -652,74 +809,64 @@ async def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore async def _update_track_data_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_update_track_data_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_track_data_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._update_track_data_initial.metadata['url'], + template_url=self._update_track_data_initial.metadata["url"], headers=_headers, params=_params, ) @@ -727,36 +874,31 @@ async def _update_track_data_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, None, response_headers) - _update_track_data_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore - + _update_track_data_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore @distributed_trace_async - async def begin_update_track_data( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + async def begin_update_track_data( + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Update the track data. @@ -767,12 +909,13 @@ async def begin_update_track_data( # pylint: disable=inconsistent-return-statem to be purged if applicable. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_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. @@ -784,19 +927,16 @@ async def begin_update_track_data( # pylint: disable=inconsistent-return-statem 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_track_data_initial( # type: ignore resource_group_name=resource_group_name, @@ -804,34 +944,30 @@ async def begin_update_track_data( # pylint: disable=inconsistent-return-statem asset_name=asset_name, track_name=track_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + 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 + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_track_data.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore + begin_update_track_data.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_transforms_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_transforms_operations.py index 5c9ef4a1a329..bda574e901b4 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_transforms_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/aio/operations/_transforms_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,18 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._transforms_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._transforms_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TransformsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: 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, @@ -52,14 +65,15 @@ def list( filter: Optional[str] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.TransformCollection]: + ) -> AsyncIterable["_models.Transform"]: """List Transforms. Lists the Transforms in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -67,31 +81,30 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransformCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.TransformCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Transform or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.media.models.Transform] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TransformCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransformCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -99,18 +112,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -126,10 +128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -140,54 +140,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - transform_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, **kwargs: Any ) -> _models.Transform: """Get Transform. Gets a Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Transform, or the result of cls(response) + :return: Transform or the result of cls(response) :rtype: ~azure.mgmt.media.models.Transform - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Transform] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Transform] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -195,10 +187,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -206,23 +197,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, transform_name: str, parameters: _models.Transform, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Transform: """Create or Update Transform. @@ -230,41 +222,114 @@ async def create_or_update( Creates or updates a new Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Transform + :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: Transform, or the result of cls(response) + :return: Transform or the result of cls(response) :rtype: ~azure.mgmt.media.models.Transform - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Transform: + """Create or Update Transform. + + Creates or updates a new Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: Union[_models.Transform, IO], + **kwargs: Any + ) -> _models.Transform: + """Create or Update Transform. + + Creates or updates a new Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Transform 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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Transform] + 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.Transform] - _json = self._serialize.body(parameters, 'Transform') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Transform") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -272,10 +337,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -284,61 +348,54 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - transform_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, **kwargs: Any ) -> None: """Delete Transform. Deletes a Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -346,10 +403,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -360,16 +416,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, transform_name: str, parameters: _models.Transform, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Transform: """Update Transform. @@ -377,41 +434,114 @@ async def update( Updates a Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Transform + :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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Transform: + """Update Transform. + + Updates a Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Transform, or the result of cls(response) + :return: Transform or the result of cls(response) :rtype: ~azure.mgmt.media.models.Transform - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: Union[_models.Transform, IO], + **kwargs: Any + ) -> _models.Transform: + """Update Transform. + + Updates a Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Transform 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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Transform] + 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.Transform] - _json = self._serialize.body(parameters, 'Transform') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Transform") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -419,10 +549,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,12 +559,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/__init__.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/__init__.py index 447f7ee72e6e..a9f6b5f4d4d4 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/__init__.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/__init__.py @@ -28,6 +28,7 @@ from ._models_py3 import AssetTrack from ._models_py3 import AssetTrackCollection from ._models_py3 import AssetTrackOperationStatus +from ._models_py3 import AsyncOperationResult from ._models_py3 import Audio from ._models_py3 import AudioAnalyzerPreset from ._models_py3 import AudioOverlay @@ -37,6 +38,7 @@ from ._models_py3 import CbcsDrmConfiguration from ._models_py3 import CencDrmConfiguration from ._models_py3 import CheckNameAvailabilityInput +from ._models_py3 import ClearKeyEncryptionConfiguration from ._models_py3 import ClipTime from ._models_py3 import Codec from ._models_py3 import CommonEncryptionCbcs @@ -70,6 +72,7 @@ from ._models_py3 import CopyAudio from ._models_py3 import CopyVideo from ._models_py3 import CrossSiteAccessPolicies +from ._models_py3 import DashSettings from ._models_py3 import DefaultKey from ._models_py3 import Deinterlace from ._models_py3 import EdgePolicies @@ -217,347 +220,352 @@ from ._models_py3 import VideoTrack from ._models_py3 import VideoTrackDescriptor - -from ._azure_media_services_enums import ( - AacAudioProfile, - AccountEncryptionKeyType, - ActionType, - AnalysisResolution, - AssetContainerPermission, - AssetStorageEncryptionFormat, - AttributeFilter, - AudioAnalysisMode, - BlurType, - ChannelMapping, - Complexity, - ContentKeyPolicyFairPlayRentalAndLeaseKeyType, - ContentKeyPolicyPlayReadyContentType, - ContentKeyPolicyPlayReadyLicenseType, - ContentKeyPolicyPlayReadyUnknownOutputPassingOption, - ContentKeyPolicyRestrictionTokenType, - CreatedByType, - DefaultAction, - DeinterlaceMode, - DeinterlaceParity, - EncoderNamedPreset, - EncryptionScheme, - EntropyMode, - FaceRedactorMode, - FilterTrackPropertyCompareOperation, - FilterTrackPropertyType, - H264Complexity, - H264RateControlMode, - H264VideoProfile, - H265Complexity, - H265VideoProfile, - InsightsType, - InterleaveOutput, - JobErrorCategory, - JobErrorCode, - JobRetry, - JobState, - LiveEventEncodingType, - LiveEventInputProtocol, - LiveEventResourceState, - LiveOutputResourceState, - MetricAggregationType, - MetricUnit, - OnErrorType, - Priority, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicNetworkAccess, - Rotation, - StorageAccountType, - StorageAuthentication, - StreamOptionsFlag, - StreamingEndpointResourceState, - StreamingLocatorContentKeyType, - StreamingPolicyStreamingProtocol, - StretchMode, - TrackAttribute, - TrackPropertyCompareOperation, - TrackPropertyType, - VideoSyncMode, - Visibility, -) +from ._azure_media_services_enums import AacAudioProfile +from ._azure_media_services_enums import AccountEncryptionKeyType +from ._azure_media_services_enums import ActionType +from ._azure_media_services_enums import AnalysisResolution +from ._azure_media_services_enums import AssetContainerPermission +from ._azure_media_services_enums import AssetStorageEncryptionFormat +from ._azure_media_services_enums import AsyncOperationStatus +from ._azure_media_services_enums import AttributeFilter +from ._azure_media_services_enums import AudioAnalysisMode +from ._azure_media_services_enums import BlurType +from ._azure_media_services_enums import ChannelMapping +from ._azure_media_services_enums import Complexity +from ._azure_media_services_enums import ContentKeyPolicyFairPlayRentalAndLeaseKeyType +from ._azure_media_services_enums import ContentKeyPolicyPlayReadyContentType +from ._azure_media_services_enums import ContentKeyPolicyPlayReadyLicenseType +from ._azure_media_services_enums import ContentKeyPolicyPlayReadyUnknownOutputPassingOption +from ._azure_media_services_enums import ContentKeyPolicyRestrictionTokenType +from ._azure_media_services_enums import CreatedByType +from ._azure_media_services_enums import DefaultAction +from ._azure_media_services_enums import DeinterlaceMode +from ._azure_media_services_enums import DeinterlaceParity +from ._azure_media_services_enums import EncoderNamedPreset +from ._azure_media_services_enums import EncryptionScheme +from ._azure_media_services_enums import EntropyMode +from ._azure_media_services_enums import FaceRedactorMode +from ._azure_media_services_enums import FilterTrackPropertyCompareOperation +from ._azure_media_services_enums import FilterTrackPropertyType +from ._azure_media_services_enums import H264Complexity +from ._azure_media_services_enums import H264RateControlMode +from ._azure_media_services_enums import H264VideoProfile +from ._azure_media_services_enums import H265Complexity +from ._azure_media_services_enums import H265VideoProfile +from ._azure_media_services_enums import InsightsType +from ._azure_media_services_enums import InterleaveOutput +from ._azure_media_services_enums import JobErrorCategory +from ._azure_media_services_enums import JobErrorCode +from ._azure_media_services_enums import JobRetry +from ._azure_media_services_enums import JobState +from ._azure_media_services_enums import LiveEventEncodingType +from ._azure_media_services_enums import LiveEventInputProtocol +from ._azure_media_services_enums import LiveEventResourceState +from ._azure_media_services_enums import LiveOutputResourceState +from ._azure_media_services_enums import MetricAggregationType +from ._azure_media_services_enums import MetricUnit +from ._azure_media_services_enums import OnErrorType +from ._azure_media_services_enums import Priority +from ._azure_media_services_enums import PrivateEndpointConnectionProvisioningState +from ._azure_media_services_enums import PrivateEndpointServiceConnectionStatus +from ._azure_media_services_enums import ProvisioningState +from ._azure_media_services_enums import PublicNetworkAccess +from ._azure_media_services_enums import Rotation +from ._azure_media_services_enums import SecurityLevel +from ._azure_media_services_enums import StorageAccountType +from ._azure_media_services_enums import StorageAuthentication +from ._azure_media_services_enums import StreamOptionsFlag +from ._azure_media_services_enums import StreamingEndpointResourceState +from ._azure_media_services_enums import StreamingLocatorContentKeyType +from ._azure_media_services_enums import StreamingPolicyStreamingProtocol +from ._azure_media_services_enums import StretchMode +from ._azure_media_services_enums import TrackAttribute +from ._azure_media_services_enums import TrackPropertyCompareOperation +from ._azure_media_services_enums import TrackPropertyType +from ._azure_media_services_enums import VideoSyncMode +from ._azure_media_services_enums import Visibility from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AacAudio', - 'AbsoluteClipTime', - 'AccessControl', - 'AccountEncryption', - 'AccountFilter', - 'AccountFilterCollection', - 'AkamaiAccessControl', - 'AkamaiSignatureHeaderAuthenticationKey', - 'ArmStreamingEndpointCapacity', - 'ArmStreamingEndpointCurrentSku', - 'ArmStreamingEndpointSku', - 'ArmStreamingEndpointSkuInfo', - 'Asset', - 'AssetCollection', - 'AssetContainerSas', - 'AssetFileEncryptionMetadata', - 'AssetFilter', - 'AssetFilterCollection', - 'AssetStreamingLocator', - 'AssetTrack', - 'AssetTrackCollection', - 'AssetTrackOperationStatus', - 'Audio', - 'AudioAnalyzerPreset', - 'AudioOverlay', - 'AudioTrack', - 'AudioTrackDescriptor', - 'BuiltInStandardEncoderPreset', - 'CbcsDrmConfiguration', - 'CencDrmConfiguration', - 'CheckNameAvailabilityInput', - 'ClipTime', - 'Codec', - 'CommonEncryptionCbcs', - 'CommonEncryptionCenc', - 'ContentKeyPolicy', - 'ContentKeyPolicyClearKeyConfiguration', - 'ContentKeyPolicyCollection', - 'ContentKeyPolicyConfiguration', - 'ContentKeyPolicyFairPlayConfiguration', - 'ContentKeyPolicyFairPlayOfflineRentalConfiguration', - 'ContentKeyPolicyOpenRestriction', - 'ContentKeyPolicyOption', - 'ContentKeyPolicyPlayReadyConfiguration', - 'ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader', - 'ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier', - 'ContentKeyPolicyPlayReadyContentKeyLocation', - 'ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction', - 'ContentKeyPolicyPlayReadyLicense', - 'ContentKeyPolicyPlayReadyPlayRight', - 'ContentKeyPolicyProperties', - 'ContentKeyPolicyRestriction', - 'ContentKeyPolicyRestrictionTokenKey', - 'ContentKeyPolicyRsaTokenKey', - 'ContentKeyPolicySymmetricTokenKey', - 'ContentKeyPolicyTokenClaim', - 'ContentKeyPolicyTokenRestriction', - 'ContentKeyPolicyUnknownConfiguration', - 'ContentKeyPolicyUnknownRestriction', - 'ContentKeyPolicyWidevineConfiguration', - 'ContentKeyPolicyX509CertificateTokenKey', - 'CopyAudio', - 'CopyVideo', - 'CrossSiteAccessPolicies', - 'DefaultKey', - 'Deinterlace', - 'EdgePolicies', - 'EdgeUsageDataCollectionPolicy', - 'EdgeUsageDataEventHub', - 'EnabledProtocols', - 'EntityNameAvailabilityCheckOutput', - 'EnvelopeEncryption', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'FaceDetectorPreset', - 'FilterTrackPropertyCondition', - 'FilterTrackSelection', - 'Filters', - 'FirstQuality', - 'Format', - 'FromAllInputFile', - 'FromEachInputFile', - 'H264Layer', - 'H264Video', - 'H265Layer', - 'H265Video', - 'H265VideoLayer', - 'Hls', - 'HlsSettings', - 'IPAccessControl', - 'IPRange', - 'Image', - 'ImageFormat', - 'InputDefinition', - 'InputFile', - 'Job', - 'JobCollection', - 'JobError', - 'JobErrorDetail', - 'JobInput', - 'JobInputAsset', - 'JobInputClip', - 'JobInputHttp', - 'JobInputSequence', - 'JobInputs', - 'JobOutput', - 'JobOutputAsset', - 'JpgFormat', - 'JpgImage', - 'JpgLayer', - 'KeyDelivery', - 'KeyVaultProperties', - 'Layer', - 'ListContainerSasInput', - 'ListContentKeysResponse', - 'ListEdgePoliciesInput', - 'ListPathsResponse', - 'ListStreamingLocatorsResponse', - 'LiveEvent', - 'LiveEventActionInput', - 'LiveEventEncoding', - 'LiveEventEndpoint', - 'LiveEventInput', - 'LiveEventInputAccessControl', - 'LiveEventInputTrackSelection', - 'LiveEventListResult', - 'LiveEventOutputTranscriptionTrack', - 'LiveEventPreview', - 'LiveEventPreviewAccessControl', - 'LiveEventTranscription', - 'LiveOutput', - 'LiveOutputListResult', - 'LogSpecification', - 'MediaService', - 'MediaServiceCollection', - 'MediaServiceIdentity', - 'MediaServiceOperationStatus', - 'MediaServiceUpdate', - 'MetricDimension', - 'MetricSpecification', - 'Mp4Format', - 'MultiBitrateFormat', - 'NoEncryption', - 'Operation', - 'OperationCollection', - 'OperationDisplay', - 'OutputFile', - 'Overlay', - 'PngFormat', - 'PngImage', - 'PngLayer', - 'PresentationTimeRange', - 'Preset', - 'PresetConfigurations', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'Properties', - 'ProxyResource', - 'Rectangle', - 'Resource', - 'ResourceIdentity', - 'SelectAudioTrackByAttribute', - 'SelectAudioTrackById', - 'SelectVideoTrackByAttribute', - 'SelectVideoTrackById', - 'ServiceSpecification', - 'StandardEncoderPreset', - 'StorageAccount', - 'StorageEncryptedAssetDecryptionData', - 'StreamingEndpoint', - 'StreamingEndpointAccessControl', - 'StreamingEndpointListResult', - 'StreamingEndpointSkuInfoListResult', - 'StreamingEntityScaleUnit', - 'StreamingLocator', - 'StreamingLocatorCollection', - 'StreamingLocatorContentKey', - 'StreamingPath', - 'StreamingPolicy', - 'StreamingPolicyCollection', - 'StreamingPolicyContentKey', - 'StreamingPolicyContentKeys', - 'StreamingPolicyFairPlayConfiguration', - 'StreamingPolicyPlayReadyConfiguration', - 'StreamingPolicyWidevineConfiguration', - 'SyncStorageKeysInput', - 'SystemData', - 'TextTrack', - 'TrackBase', - 'TrackDescriptor', - 'TrackPropertyCondition', - 'TrackSelection', - 'TrackedResource', - 'Transform', - 'TransformCollection', - 'TransformOutput', - 'TransportStreamFormat', - 'UserAssignedManagedIdentity', - 'UtcClipTime', - 'Video', - 'VideoAnalyzerPreset', - 'VideoLayer', - 'VideoOverlay', - 'VideoTrack', - 'VideoTrackDescriptor', - 'AacAudioProfile', - 'AccountEncryptionKeyType', - 'ActionType', - 'AnalysisResolution', - 'AssetContainerPermission', - 'AssetStorageEncryptionFormat', - 'AttributeFilter', - 'AudioAnalysisMode', - 'BlurType', - 'ChannelMapping', - 'Complexity', - 'ContentKeyPolicyFairPlayRentalAndLeaseKeyType', - 'ContentKeyPolicyPlayReadyContentType', - 'ContentKeyPolicyPlayReadyLicenseType', - 'ContentKeyPolicyPlayReadyUnknownOutputPassingOption', - 'ContentKeyPolicyRestrictionTokenType', - 'CreatedByType', - 'DefaultAction', - 'DeinterlaceMode', - 'DeinterlaceParity', - 'EncoderNamedPreset', - 'EncryptionScheme', - 'EntropyMode', - 'FaceRedactorMode', - 'FilterTrackPropertyCompareOperation', - 'FilterTrackPropertyType', - 'H264Complexity', - 'H264RateControlMode', - 'H264VideoProfile', - 'H265Complexity', - 'H265VideoProfile', - 'InsightsType', - 'InterleaveOutput', - 'JobErrorCategory', - 'JobErrorCode', - 'JobRetry', - 'JobState', - 'LiveEventEncodingType', - 'LiveEventInputProtocol', - 'LiveEventResourceState', - 'LiveOutputResourceState', - 'MetricAggregationType', - 'MetricUnit', - 'OnErrorType', - 'Priority', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'Rotation', - 'StorageAccountType', - 'StorageAuthentication', - 'StreamOptionsFlag', - 'StreamingEndpointResourceState', - 'StreamingLocatorContentKeyType', - 'StreamingPolicyStreamingProtocol', - 'StretchMode', - 'TrackAttribute', - 'TrackPropertyCompareOperation', - 'TrackPropertyType', - 'VideoSyncMode', - 'Visibility', + "AacAudio", + "AbsoluteClipTime", + "AccessControl", + "AccountEncryption", + "AccountFilter", + "AccountFilterCollection", + "AkamaiAccessControl", + "AkamaiSignatureHeaderAuthenticationKey", + "ArmStreamingEndpointCapacity", + "ArmStreamingEndpointCurrentSku", + "ArmStreamingEndpointSku", + "ArmStreamingEndpointSkuInfo", + "Asset", + "AssetCollection", + "AssetContainerSas", + "AssetFileEncryptionMetadata", + "AssetFilter", + "AssetFilterCollection", + "AssetStreamingLocator", + "AssetTrack", + "AssetTrackCollection", + "AssetTrackOperationStatus", + "AsyncOperationResult", + "Audio", + "AudioAnalyzerPreset", + "AudioOverlay", + "AudioTrack", + "AudioTrackDescriptor", + "BuiltInStandardEncoderPreset", + "CbcsDrmConfiguration", + "CencDrmConfiguration", + "CheckNameAvailabilityInput", + "ClearKeyEncryptionConfiguration", + "ClipTime", + "Codec", + "CommonEncryptionCbcs", + "CommonEncryptionCenc", + "ContentKeyPolicy", + "ContentKeyPolicyClearKeyConfiguration", + "ContentKeyPolicyCollection", + "ContentKeyPolicyConfiguration", + "ContentKeyPolicyFairPlayConfiguration", + "ContentKeyPolicyFairPlayOfflineRentalConfiguration", + "ContentKeyPolicyOpenRestriction", + "ContentKeyPolicyOption", + "ContentKeyPolicyPlayReadyConfiguration", + "ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader", + "ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier", + "ContentKeyPolicyPlayReadyContentKeyLocation", + "ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction", + "ContentKeyPolicyPlayReadyLicense", + "ContentKeyPolicyPlayReadyPlayRight", + "ContentKeyPolicyProperties", + "ContentKeyPolicyRestriction", + "ContentKeyPolicyRestrictionTokenKey", + "ContentKeyPolicyRsaTokenKey", + "ContentKeyPolicySymmetricTokenKey", + "ContentKeyPolicyTokenClaim", + "ContentKeyPolicyTokenRestriction", + "ContentKeyPolicyUnknownConfiguration", + "ContentKeyPolicyUnknownRestriction", + "ContentKeyPolicyWidevineConfiguration", + "ContentKeyPolicyX509CertificateTokenKey", + "CopyAudio", + "CopyVideo", + "CrossSiteAccessPolicies", + "DashSettings", + "DefaultKey", + "Deinterlace", + "EdgePolicies", + "EdgeUsageDataCollectionPolicy", + "EdgeUsageDataEventHub", + "EnabledProtocols", + "EntityNameAvailabilityCheckOutput", + "EnvelopeEncryption", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "FaceDetectorPreset", + "FilterTrackPropertyCondition", + "FilterTrackSelection", + "Filters", + "FirstQuality", + "Format", + "FromAllInputFile", + "FromEachInputFile", + "H264Layer", + "H264Video", + "H265Layer", + "H265Video", + "H265VideoLayer", + "Hls", + "HlsSettings", + "IPAccessControl", + "IPRange", + "Image", + "ImageFormat", + "InputDefinition", + "InputFile", + "Job", + "JobCollection", + "JobError", + "JobErrorDetail", + "JobInput", + "JobInputAsset", + "JobInputClip", + "JobInputHttp", + "JobInputSequence", + "JobInputs", + "JobOutput", + "JobOutputAsset", + "JpgFormat", + "JpgImage", + "JpgLayer", + "KeyDelivery", + "KeyVaultProperties", + "Layer", + "ListContainerSasInput", + "ListContentKeysResponse", + "ListEdgePoliciesInput", + "ListPathsResponse", + "ListStreamingLocatorsResponse", + "LiveEvent", + "LiveEventActionInput", + "LiveEventEncoding", + "LiveEventEndpoint", + "LiveEventInput", + "LiveEventInputAccessControl", + "LiveEventInputTrackSelection", + "LiveEventListResult", + "LiveEventOutputTranscriptionTrack", + "LiveEventPreview", + "LiveEventPreviewAccessControl", + "LiveEventTranscription", + "LiveOutput", + "LiveOutputListResult", + "LogSpecification", + "MediaService", + "MediaServiceCollection", + "MediaServiceIdentity", + "MediaServiceOperationStatus", + "MediaServiceUpdate", + "MetricDimension", + "MetricSpecification", + "Mp4Format", + "MultiBitrateFormat", + "NoEncryption", + "Operation", + "OperationCollection", + "OperationDisplay", + "OutputFile", + "Overlay", + "PngFormat", + "PngImage", + "PngLayer", + "PresentationTimeRange", + "Preset", + "PresetConfigurations", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "Properties", + "ProxyResource", + "Rectangle", + "Resource", + "ResourceIdentity", + "SelectAudioTrackByAttribute", + "SelectAudioTrackById", + "SelectVideoTrackByAttribute", + "SelectVideoTrackById", + "ServiceSpecification", + "StandardEncoderPreset", + "StorageAccount", + "StorageEncryptedAssetDecryptionData", + "StreamingEndpoint", + "StreamingEndpointAccessControl", + "StreamingEndpointListResult", + "StreamingEndpointSkuInfoListResult", + "StreamingEntityScaleUnit", + "StreamingLocator", + "StreamingLocatorCollection", + "StreamingLocatorContentKey", + "StreamingPath", + "StreamingPolicy", + "StreamingPolicyCollection", + "StreamingPolicyContentKey", + "StreamingPolicyContentKeys", + "StreamingPolicyFairPlayConfiguration", + "StreamingPolicyPlayReadyConfiguration", + "StreamingPolicyWidevineConfiguration", + "SyncStorageKeysInput", + "SystemData", + "TextTrack", + "TrackBase", + "TrackDescriptor", + "TrackPropertyCondition", + "TrackSelection", + "TrackedResource", + "Transform", + "TransformCollection", + "TransformOutput", + "TransportStreamFormat", + "UserAssignedManagedIdentity", + "UtcClipTime", + "Video", + "VideoAnalyzerPreset", + "VideoLayer", + "VideoOverlay", + "VideoTrack", + "VideoTrackDescriptor", + "AacAudioProfile", + "AccountEncryptionKeyType", + "ActionType", + "AnalysisResolution", + "AssetContainerPermission", + "AssetStorageEncryptionFormat", + "AsyncOperationStatus", + "AttributeFilter", + "AudioAnalysisMode", + "BlurType", + "ChannelMapping", + "Complexity", + "ContentKeyPolicyFairPlayRentalAndLeaseKeyType", + "ContentKeyPolicyPlayReadyContentType", + "ContentKeyPolicyPlayReadyLicenseType", + "ContentKeyPolicyPlayReadyUnknownOutputPassingOption", + "ContentKeyPolicyRestrictionTokenType", + "CreatedByType", + "DefaultAction", + "DeinterlaceMode", + "DeinterlaceParity", + "EncoderNamedPreset", + "EncryptionScheme", + "EntropyMode", + "FaceRedactorMode", + "FilterTrackPropertyCompareOperation", + "FilterTrackPropertyType", + "H264Complexity", + "H264RateControlMode", + "H264VideoProfile", + "H265Complexity", + "H265VideoProfile", + "InsightsType", + "InterleaveOutput", + "JobErrorCategory", + "JobErrorCode", + "JobRetry", + "JobState", + "LiveEventEncodingType", + "LiveEventInputProtocol", + "LiveEventResourceState", + "LiveOutputResourceState", + "MetricAggregationType", + "MetricUnit", + "OnErrorType", + "Priority", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicNetworkAccess", + "Rotation", + "SecurityLevel", + "StorageAccountType", + "StorageAuthentication", + "StreamOptionsFlag", + "StreamingEndpointResourceState", + "StreamingLocatorContentKeyType", + "StreamingPolicyStreamingProtocol", + "StretchMode", + "TrackAttribute", + "TrackPropertyCompareOperation", + "TrackPropertyType", + "VideoSyncMode", + "Visibility", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_azure_media_services_enums.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_azure_media_services_enums.py index f0defd7290ea..e59fafe8a3e2 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_azure_media_services_enums.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_azure_media_services_enums.py @@ -11,8 +11,7 @@ class AacAudioProfile(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The encoding profile to be used when encoding audio with AAC. - """ + """The encoding profile to be used when encoding audio with AAC.""" #: Specifies that the output audio is to be encoded into AAC Low Complexity profile (AAC-LC). AAC_LC = "AacLc" @@ -21,22 +20,23 @@ class AacAudioProfile(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Specifies that the output audio is to be encoded into HE-AAC v2 profile. HE_AAC_V2 = "HeAacV2" + class AccountEncryptionKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the Account Key. - """ + """The type of key used to encrypt the Account Key.""" #: The Account Key is encrypted with a System Key. SYSTEM_KEY = "SystemKey" #: The Account Key is encrypted with a Customer Key. CUSTOMER_KEY = "CustomerKey" + class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the action type. - """ + """Indicates the action type.""" #: An internal action. INTERNAL = "Internal" + class AnalysisResolution(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the maximum resolution at which your video is analyzed. The default behavior is "SourceResolution," which will keep the input video at its original resolution when analyzed. @@ -52,9 +52,9 @@ class AnalysisResolution(str, Enum, metaclass=CaseInsensitiveEnumMeta): SOURCE_RESOLUTION = "SourceResolution" STANDARD_DEFINITION = "StandardDefinition" + class AssetContainerPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The permissions to set on the SAS URL. - """ + """The permissions to set on the SAS URL.""" #: The SAS URL will allow read access to the container. READ = "Read" @@ -63,9 +63,9 @@ class AssetContainerPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The SAS URL will allow read, write and delete access to the container. READ_WRITE_DELETE = "ReadWriteDelete" + class AssetStorageEncryptionFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Asset encryption format. One of None or MediaStorageEncryption. - """ + """The Asset encryption format. One of None or MediaStorageEncryption.""" #: The Asset does not use client-side storage encryption (this is the only allowed value for new #: Assets). @@ -73,9 +73,17 @@ class AssetStorageEncryptionFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta) #: The Asset is encrypted with Media Services client-side encryption. MEDIA_STORAGE_CLIENT_ENCRYPTION = "MediaStorageClientEncryption" + +class AsyncOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Operation status of the async operation.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + IN_PROGRESS = "InProgress" + + class AttributeFilter(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of AttributeFilter to apply to the TrackAttribute in order to select the tracks. - """ + """The type of AttributeFilter to apply to the TrackAttribute in order to select the tracks.""" #: All tracks will be included. ALL = "All" @@ -88,6 +96,7 @@ class AttributeFilter(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Any tracks that have an attribute equal to the value given will be included. VALUE_EQUALS = "ValueEquals" + class AudioAnalysisMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen. @@ -102,21 +111,22 @@ class AudioAnalysisMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: not included in this mode. BASIC = "Basic" + class BlurType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Blur type - """ + """Blur type.""" - #: Box: debug filter, bounding box only. + #: Box: debug filter, bounding box only BOX = "Box" - #: Low: box-car blur filter. + #: Low: box-car blur filter LOW = "Low" - #: Med: Gaussian blur filter. + #: Med: Gaussian blur filter MED = "Med" - #: High: Confuse blur filter. + #: High: Confuse blur filter HIGH = "High" - #: Black: Black out filter. + #: Black: Black out filter BLACK = "Black" + class ChannelMapping(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. @@ -139,6 +149,7 @@ class ChannelMapping(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The Right Stereo channel. Sometimes referred to as Down Mix Right. STEREO_RIGHT = "StereoRight" + class Complexity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allows you to configure the encoder settings to control the balance between speed and quality. Example: set Complexity as Speed for faster encoding but less compression efficiency. @@ -153,9 +164,9 @@ class Complexity(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: expense of slower overall encode time. QUALITY = "Quality" + class ContentKeyPolicyFairPlayRentalAndLeaseKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rental and lease key type. - """ + """The rental and lease key type.""" #: Represents a ContentKeyPolicyFairPlayRentalAndLeaseKeyType that is unavailable in current API #: version. @@ -164,14 +175,14 @@ class ContentKeyPolicyFairPlayRentalAndLeaseKeyType(str, Enum, metaclass=CaseIns UNDEFINED = "Undefined" #: Dual expiry for offline rental. DUAL_EXPIRY = "DualExpiry" - #: Content key can be persisted with an unlimited duration. + #: Content key can be persisted with an unlimited duration PERSISTENT_UNLIMITED = "PersistentUnlimited" - #: Content key can be persisted and the valid duration is limited by the Rental Duration value. + #: Content key can be persisted and the valid duration is limited by the Rental Duration value PERSISTENT_LIMITED = "PersistentLimited" + class ContentKeyPolicyPlayReadyContentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The PlayReady content type. - """ + """The PlayReady content type.""" #: Represents a ContentKeyPolicyPlayReadyContentType that is unavailable in current API version. UNKNOWN = "Unknown" @@ -182,9 +193,9 @@ class ContentKeyPolicyPlayReadyContentType(str, Enum, metaclass=CaseInsensitiveE #: Ultraviolet streaming content type. ULTRA_VIOLET_STREAMING = "UltraVioletStreaming" + class ContentKeyPolicyPlayReadyLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The license type. - """ + """The license type.""" #: Represents a ContentKeyPolicyPlayReadyLicenseType that is unavailable in current API version. UNKNOWN = "Unknown" @@ -193,9 +204,9 @@ class ContentKeyPolicyPlayReadyLicenseType(str, Enum, metaclass=CaseInsensitiveE #: Persistent license. Allows offline playback. PERSISTENT = "Persistent" + class ContentKeyPolicyPlayReadyUnknownOutputPassingOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Configures Unknown output handling settings of the license. - """ + """Configures Unknown output handling settings of the license.""" #: Represents a ContentKeyPolicyPlayReadyUnknownOutputPassingOption that is unavailable in current #: API version. @@ -208,9 +219,9 @@ class ContentKeyPolicyPlayReadyUnknownOutputPassingOption(str, Enum, metaclass=C #: constrained resolution. ALLOWED_WITH_VIDEO_CONSTRICTION = "AllowedWithVideoConstriction" + class ContentKeyPolicyRestrictionTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of token. - """ + """The type of token.""" #: Represents a ContentKeyPolicyRestrictionTokenType that is unavailable in current API version. UNKNOWN = "Unknown" @@ -219,47 +230,47 @@ class ContentKeyPolicyRestrictionTokenType(str, Enum, metaclass=CaseInsensitiveE #: JSON Web Token. JWT = "Jwt" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The behavior for IP access control in Key Delivery. - """ + """The behavior for IP access control in Key Delivery.""" #: All public IP addresses are allowed. ALLOW = "Allow" #: Public IP addresses are blocked. DENY = "Deny" + class DeinterlaceMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The deinterlacing mode. Defaults to AutoPixelAdaptive. - """ + """The deinterlacing mode. Defaults to AutoPixelAdaptive.""" #: Disables de-interlacing of the source video. OFF = "Off" #: Apply automatic pixel adaptive de-interlacing on each frame in the input video. AUTO_PIXEL_ADAPTIVE = "AutoPixelAdaptive" + class DeinterlaceParity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The field parity for de-interlacing, defaults to Auto. - """ + """The field parity for de-interlacing, defaults to Auto.""" - #: Automatically detect the order of fields. + #: Automatically detect the order of fields AUTO = "Auto" #: Apply top field first processing of input video. TOP_FIELD_FIRST = "TopFieldFirst" #: Apply bottom field first processing of input video. BOTTOM_FIELD_FIRST = "BottomFieldFirst" + class EncoderNamedPreset(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The built-in preset to be used for encoding videos. - """ + """The built-in preset to be used for encoding videos.""" #: Produces an MP4 file where the video is encoded with H.264 codec at 2200 kbps and a picture #: height of 480 pixels, and the stereo audio is encoded with AAC-LC codec at 128 kbps. @@ -326,19 +337,20 @@ class EncoderNamedPreset(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: height of 2160 pixels, and the stereo audio is encoded with AAC-LC codec at 128 kbps. H265_SINGLE_BITRATE4_K = "H265SingleBitrate4K" + class EncryptionScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Encryption scheme - """ + """Encryption scheme.""" - #: NoEncryption scheme. + #: NoEncryption scheme NO_ENCRYPTION = "NoEncryption" - #: EnvelopeEncryption scheme. + #: EnvelopeEncryption scheme ENVELOPE_ENCRYPTION = "EnvelopeEncryption" - #: CommonEncryptionCenc scheme. + #: CommonEncryptionCenc scheme COMMON_ENCRYPTION_CENC = "CommonEncryptionCenc" - #: CommonEncryptionCbcs scheme. + #: CommonEncryptionCbcs scheme COMMON_ENCRYPTION_CBCS = "CommonEncryptionCbcs" + class EntropyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The entropy mode to be used for this layer. If not specified, the encoder chooses the mode that is appropriate for the profile and level. @@ -349,6 +361,7 @@ class EntropyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Context Adaptive Variable Length Coder (CAVLC) entropy encoding. CAVLC = "Cavlc" + class FaceRedactorMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This mode provides the ability to choose between the following settings: 1) Analyze - For detection only.This mode generates a metadata JSON file marking appearances of faces throughout @@ -368,18 +381,18 @@ class FaceRedactorMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: not desired. COMBINED = "Combined" + class FilterTrackPropertyCompareOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The track property condition operation. - """ + """The track property condition operation.""" #: The equal operation. EQUAL = "Equal" #: The not equal operation. NOT_EQUAL = "NotEqual" + class FilterTrackPropertyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The track property type. - """ + """The track property type.""" #: The unknown track property type. UNKNOWN = "Unknown" @@ -394,9 +407,9 @@ class FilterTrackPropertyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The bitrate. BITRATE = "Bitrate" + class H264Complexity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Tells the encoder how to choose its encoding settings. The default value is Balanced. - """ + """Tells the encoder how to choose its encoding settings. The default value is Balanced.""" #: Tells the encoder to use settings that are optimized for faster encoding. Quality is sacrificed #: to decrease encoding time. @@ -407,9 +420,9 @@ class H264Complexity(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: expense of slower overall encode time. QUALITY = "Quality" + class H264RateControlMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The video rate control mode - """ + """The video rate control mode.""" #: Average Bitrate (ABR) mode that hits the target bitrate: Default mode. ABR = "ABR" @@ -418,15 +431,15 @@ class H264RateControlMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Constant Rate Factor (CRF) mode that targets at constant subjective quality. CRF = "CRF" + class H264VideoProfile(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """We currently support Baseline, Main, High, High422, High444. Default is Auto. - """ + """We currently support Baseline, Main, High, High422, High444. Default is Auto.""" #: Tells the encoder to automatically determine the appropriate H.264 profile. AUTO = "Auto" - #: Baseline profile. + #: Baseline profile BASELINE = "Baseline" - #: Main profile. + #: Main profile MAIN = "Main" #: High profile. HIGH = "High" @@ -435,6 +448,7 @@ class H264VideoProfile(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: High 4:4:4 predictive profile. HIGH444 = "High444" + class H265Complexity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Tells the encoder how to choose its encoding settings. Quality will provide for a higher compression ratio but at a higher cost and longer compute time. Speed will produce a @@ -450,18 +464,19 @@ class H265Complexity(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: expense of slower overall encode time. QUALITY = "Quality" + class H265VideoProfile(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """We currently support Main. Default is Auto. - """ + """We currently support Main. Default is Auto.""" #: Tells the encoder to automatically determine the appropriate H.265 profile. AUTO = "Auto" #: Main profile - #: (https://x265.readthedocs.io/en/default/cli.html?highlight=profile#profile-level-tier). + #: (https://x265.readthedocs.io/en/default/cli.html?highlight=profile#profile-level-tier) MAIN = "Main" - #: Main 10 profile (https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding#Main_10). + #: Main 10 profile (https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding#Main_10) MAIN10 = "Main10" + class InsightsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the type of insights that you want the service to generate. The allowed values are 'AudioInsightsOnly', 'VideoInsightsOnly', and 'AllInsights'. The default is AllInsights. If you @@ -479,6 +494,7 @@ class InsightsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Generate both audio and video insights. Fails if either audio or video Insights fail. ALL_INSIGHTS = "AllInsights" + class InterleaveOutput(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sets the interleave mode of the output to control how audio and video are stored in the container format. Example: set InterleavedOutput as NonInterleavedOutput to produce audio-only @@ -490,9 +506,9 @@ class InterleaveOutput(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The output includes both audio and video. INTERLEAVED_OUTPUT = "InterleavedOutput" + class JobErrorCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Helps with categorization of errors. - """ + """Helps with categorization of errors.""" #: The error is service related. SERVICE = "Service" @@ -505,9 +521,9 @@ class JobErrorCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The error is related to data in the input files. CONTENT = "Content" + class JobErrorCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Error code describing the error. - """ + """Error code describing the error.""" #: Fatal service error, please contact support. SERVICE_ERROR = "ServiceError" @@ -536,6 +552,7 @@ class JobErrorCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: file/codec), check the validity of the input files. CONTENT_UNSUPPORTED = "ContentUnsupported" + class JobRetry(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact Azure support via Azure Portal. @@ -547,9 +564,9 @@ class JobRetry(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Issue may be resolved after waiting for a period of time and resubmitting the same Job. MAY_RETRY = "MayRetry" + class JobState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the state of the JobOutput. - """ + """Describes the state of the JobOutput.""" #: The job was canceled. This is a final state for the job. CANCELED = "Canceled" @@ -568,6 +585,7 @@ class JobState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: queued and processing states. SCHEDULED = "Scheduled" + class LiveEventEncodingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Live event type. When encodingType is set to PassthroughBasic or PassthroughStandard, the service simply passes through the incoming video and audio layer(s) to the output. When @@ -594,6 +612,7 @@ class LiveEventEncodingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: and up to 3 concurrent live outputs are allowed. PASSTHROUGH_STANDARD = "PassthroughStandard" + class LiveEventInputProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The input protocol for the live event. This is specified at creation time and cannot be updated. @@ -604,6 +623,7 @@ class LiveEventInputProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: RTMP input will be sent by the contribution encoder to the live event. RTMP = "RTMP" + class LiveEventResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource state of the live event. See https://go.microsoft.com/fwlink/?linkid=2139012 for more information. @@ -635,9 +655,9 @@ class LiveEventResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: streaming are not allowed during this state. DELETING = "Deleting" + class LiveOutputResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource state of the live output. - """ + """The resource state of the live output.""" #: Live output is being created. No content is archived in the asset until the live output is in #: running state. @@ -649,9 +669,9 @@ class LiveOutputResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Any streaming URLs created on the live output asset continue to work. DELETING = "Deleting" + class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The metric aggregation type - """ + """The metric aggregation type.""" #: The average. AVERAGE = "Average" @@ -660,9 +680,9 @@ class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The sum. TOTAL = "Total" + class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The metric unit - """ + """The metric unit.""" #: The number of bytes. BYTES = "Bytes" @@ -671,6 +691,7 @@ class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The number of milliseconds. MILLISECONDS = "Milliseconds" + class OnErrorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A Transform can define more than one outputs. This property defines what the service should do when one output fails - either continue to produce other outputs, or, stop the other outputs. @@ -685,6 +706,7 @@ class OnErrorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: continue. CONTINUE_JOB = "ContinueJob" + class Priority(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sets the relative priority of the TransformOutputs within a Transform. This sets the priority that the service uses for processing TransformOutputs. The default priority is Normal. @@ -698,26 +720,26 @@ class Priority(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Used for TransformOutputs that should take precedence over others. HIGH = "High" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Media Services account. - """ + """Provisioning state of the Media Services account.""" #: Provisioning state failed. FAILED = "Failed" @@ -726,18 +748,18 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Provisioning state succeeded. SUCCEEDED = "Succeeded" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether or not public network access is allowed for resources under the Media Services account. - """ + """Whether or not public network access is allowed for resources under the Media Services account.""" #: Public network access is enabled. ENABLED = "Enabled" #: Public network access is disabled. DISABLED = "Disabled" + class Rotation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rotation, if any, to be applied to the input video, before it is encoded. Default is Auto - """ + """The rotation, if any, to be applied to the input video, before it is encoded. Default is Auto.""" #: Automatically detect and rotate as needed. AUTO = "Auto" @@ -753,32 +775,48 @@ class Rotation(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Rotate 270 degrees clockwise. ROTATE270 = "Rotate270" + +class SecurityLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The security level.""" + + #: Represents a SecurityLevel that is unavailable in current API version. + UNKNOWN = "Unknown" + #: For clients under development or test. No protection against unauthorized use. + SL150 = "SL150" + #: For hardened devices and applications consuming commercial content. Software or hardware + #: protection. + SL2000 = "SL2000" + #: For hardened devices only. Hardware protection. + SL3000 = "SL3000" + + class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the storage account. - """ + """The type of the storage account.""" #: The primary storage account for the Media Services account. PRIMARY = "Primary" #: A secondary storage account for the Media Services account. SECONDARY = "Secondary" + class StorageAuthentication(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAuthentication.""" #: System authentication. SYSTEM = "System" #: Managed Identity authentication. MANAGED_IDENTITY = "ManagedIdentity" + class StreamingEndpointResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource state of the streaming endpoint. - """ + """The resource state of the streaming endpoint.""" #: The initial state of a streaming endpoint after creation. Content is not ready to be streamed #: from this endpoint. STOPPED = "Stopped" #: The streaming endpoint is transitioning to the running state. STARTING = "Starting" - #: The streaming endpoint is running. It is able to stream content to clients. + #: The streaming endpoint is running. It is able to stream content to clients RUNNING = "Running" #: The streaming endpoint is transitioning to the stopped state. STOPPING = "Stopping" @@ -787,31 +825,33 @@ class StreamingEndpointResourceState(str, Enum, metaclass=CaseInsensitiveEnumMet #: The streaming endpoint is increasing or decreasing scale units. SCALING = "Scaling" + class StreamingLocatorContentKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Encryption type of Content Key - """ + """Encryption type of Content Key.""" - #: Common Encryption using CENC. + #: Common Encryption using CENC COMMON_ENCRYPTION_CENC = "CommonEncryptionCenc" - #: Common Encryption using CBCS. + #: Common Encryption using CBCS COMMON_ENCRYPTION_CBCS = "CommonEncryptionCbcs" - #: Envelope Encryption. + #: Envelope Encryption ENVELOPE_ENCRYPTION = "EnvelopeEncryption" + class StreamingPolicyStreamingProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Streaming protocol - """ + """Streaming protocol.""" - #: HLS protocol. + #: HLS protocol HLS = "Hls" - #: DASH protocol. + #: DASH protocol DASH = "Dash" - #: SmoothStreaming protocol. + #: SmoothStreaming protocol SMOOTH_STREAMING = "SmoothStreaming" - #: Download protocol. + #: Download protocol DOWNLOAD = "Download" + class StreamOptionsFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StreamOptionsFlag.""" #: Live streaming with no special latency optimizations. DEFAULT = "Default" @@ -823,9 +863,10 @@ class StreamOptionsFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: all other scenarios. LOW_LATENCY_V2 = "LowLatencyV2" + class StretchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resizing mode - how the input video will be resized to fit the desired output - resolution(s). Default is AutoSize + resolution(s). Default is AutoSize. """ #: Strictly respect the output resolution without considering the pixel aspect ratio or display @@ -843,36 +884,36 @@ class StretchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: and pillar box regions 280 pixels wide at the left and right. AUTO_FIT = "AutoFit" + class TrackAttribute(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The TrackAttribute to filter the tracks by. - """ + """The TrackAttribute to filter the tracks by.""" #: The bitrate of the track. BITRATE = "Bitrate" #: The language of the track. LANGUAGE = "Language" + class TrackPropertyCompareOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Track property condition operation - """ + """Track property condition operation.""" - #: Unknown track property compare operation. + #: Unknown track property compare operation UNKNOWN = "Unknown" - #: Equal operation. + #: Equal operation EQUAL = "Equal" + class TrackPropertyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Track property type - """ + """Track property type.""" - #: Unknown track property. + #: Unknown track property UNKNOWN = "Unknown" - #: Track FourCC. + #: Track FourCC FOUR_CC = "FourCC" + class VideoSyncMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Video Sync Mode - """ + """The Video Sync Mode.""" #: This is the default method. Chooses between Cfr and Vfr depending on muxer capabilities. For #: output format MP4, the default mode is Cfr. @@ -881,18 +922,19 @@ class VideoSyncMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: writer. Recommended when the input source has variable frame rate, and are attempting to #: produce multiple layers for adaptive streaming in the output which have aligned GOP boundaries. #: Note: if two or more frames in the input have duplicate timestamps, then the output will also - #: have the same behavior. + #: have the same behavior PASSTHROUGH = "Passthrough" #: Input frames will be repeated and/or dropped as needed to achieve exactly the requested #: constant frame rate. Recommended when the output frame rate is explicitly set at a specified - #: value. + #: value CFR = "Cfr" #: Similar to the Passthrough mode, but if the input has frames that have duplicate timestamps, #: then only one frame is passed through to the output, and others are dropped. Recommended when #: the number of output frames is expected to be equal to the number of input frames. For example, - #: the output is used to calculate a quality metric like PSNR against the input. + #: the output is used to calculate a quality metric like PSNR against the input VFR = "Vfr" + class Visibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When PlayerVisibility is set to "Visible", the text track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to "Hidden", the diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_models_py3.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_models_py3.py index 19a3c5beb967..3ceebab425c3 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_models_py3.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,53 +10,52 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class Codec(msrest.serialization.Model): +class Codec(_serialization.Model): """Describes the basic properties of all codecs. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: Audio, CopyAudio, CopyVideo, Video. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + Audio, CopyAudio, CopyVideo, Video All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.Audio': 'Audio', '#Microsoft.Media.CopyAudio': 'CopyAudio', '#Microsoft.Media.CopyVideo': 'CopyVideo', '#Microsoft.Media.Video': 'Video'} + "odata_type": { + "#Microsoft.Media.Audio": "Audio", + "#Microsoft.Media.CopyAudio": "CopyAudio", + "#Microsoft.Media.CopyVideo": "CopyVideo", + "#Microsoft.Media.Video": "Video", + } } - def __init__( - self, - *, - label: Optional[str] = None, - **kwargs - ): + def __init__(self, *, label: Optional[str] = None, **kwargs): """ :keyword label: An optional label for the codec. The label can be used to control muxing behavior. :paramtype label: str """ - super(Codec, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.label = label @@ -63,12 +63,12 @@ def __init__( class Audio(Codec): """Defines the common properties for all audio codecs. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AacAudio. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AacAudio All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -81,20 +81,18 @@ class Audio(Codec): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'channels': {'key': 'channels', 'type': 'int'}, - 'sampling_rate': {'key': 'samplingRate', 'type': 'int'}, - 'bitrate': {'key': 'bitrate', 'type': 'int'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "channels": {"key": "channels", "type": "int"}, + "sampling_rate": {"key": "samplingRate", "type": "int"}, + "bitrate": {"key": "bitrate", "type": "int"}, } - _subtype_map = { - 'odata_type': {'#Microsoft.Media.AacAudio': 'AacAudio'} - } + _subtype_map = {"odata_type": {"#Microsoft.Media.AacAudio": "AacAudio"}} def __init__( self, @@ -116,8 +114,8 @@ def __init__( :keyword bitrate: The bitrate, in bits per second, of the output encoded audio. :paramtype bitrate: int """ - super(Audio, self).__init__(label=label, **kwargs) - self.odata_type = '#Microsoft.Media.Audio' # type: str + super().__init__(label=label, **kwargs) + self.odata_type = "#Microsoft.Media.Audio" # type: str self.channels = channels self.sampling_rate = sampling_rate self.bitrate = bitrate @@ -128,7 +126,7 @@ class AacAudio(Audio): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -139,21 +137,21 @@ class AacAudio(Audio): :ivar bitrate: The bitrate, in bits per second, of the output encoded audio. :vartype bitrate: int :ivar profile: The encoding profile to be used when encoding audio with AAC. Known values are: - "AacLc", "HeAacV1", "HeAacV2". + "AacLc", "HeAacV1", and "HeAacV2". :vartype profile: str or ~azure.mgmt.media.models.AacAudioProfile """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'channels': {'key': 'channels', 'type': 'int'}, - 'sampling_rate': {'key': 'samplingRate', 'type': 'int'}, - 'bitrate': {'key': 'bitrate', 'type': 'int'}, - 'profile': {'key': 'profile', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "channels": {"key": "channels", "type": "int"}, + "sampling_rate": {"key": "samplingRate", "type": "int"}, + "bitrate": {"key": "bitrate", "type": "int"}, + "profile": {"key": "profile", "type": "str"}, } def __init__( @@ -177,45 +175,44 @@ def __init__( :keyword bitrate: The bitrate, in bits per second, of the output encoded audio. :paramtype bitrate: int :keyword profile: The encoding profile to be used when encoding audio with AAC. Known values - are: "AacLc", "HeAacV1", "HeAacV2". + are: "AacLc", "HeAacV1", and "HeAacV2". :paramtype profile: str or ~azure.mgmt.media.models.AacAudioProfile """ - super(AacAudio, self).__init__(label=label, channels=channels, sampling_rate=sampling_rate, bitrate=bitrate, **kwargs) - self.odata_type = '#Microsoft.Media.AacAudio' # type: str + super().__init__(label=label, channels=channels, sampling_rate=sampling_rate, bitrate=bitrate, **kwargs) + self.odata_type = "#Microsoft.Media.AacAudio" # type: str self.profile = profile -class ClipTime(msrest.serialization.Model): +class ClipTime(_serialization.Model): """Base class for specifying a clip time. Use sub classes of this class to specify the time position in the media. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AbsoluteClipTime, UtcClipTime. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AbsoluteClipTime, UtcClipTime All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.AbsoluteClipTime': 'AbsoluteClipTime', '#Microsoft.Media.UtcClipTime': 'UtcClipTime'} + "odata_type": { + "#Microsoft.Media.AbsoluteClipTime": "AbsoluteClipTime", + "#Microsoft.Media.UtcClipTime": "UtcClipTime", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(ClipTime, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -224,44 +221,39 @@ class AbsoluteClipTime(ClipTime): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar time: Required. The time position on the timeline of the input media. It is usually - specified as an ISO8601 period. e.g PT30S for 30 seconds. + :ivar time: The time position on the timeline of the input media. It is usually specified as an + ISO8601 period. e.g PT30S for 30 seconds. Required. :vartype time: ~datetime.timedelta """ _validation = { - 'odata_type': {'required': True}, - 'time': {'required': True}, + "odata_type": {"required": True}, + "time": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'duration'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "time": {"key": "time", "type": "duration"}, } - def __init__( - self, - *, - time: datetime.timedelta, - **kwargs - ): + def __init__(self, *, time: datetime.timedelta, **kwargs): """ - :keyword time: Required. The time position on the timeline of the input media. It is usually - specified as an ISO8601 period. e.g PT30S for 30 seconds. + :keyword time: The time position on the timeline of the input media. It is usually specified as + an ISO8601 period. e.g PT30S for 30 seconds. Required. :paramtype time: ~datetime.timedelta """ - super(AbsoluteClipTime, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.AbsoluteClipTime' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.AbsoluteClipTime" # type: str self.time = time -class AccessControl(msrest.serialization.Model): +class AccessControl(_serialization.Model): """AccessControl. :ivar default_action: The behavior for IP access control in Key Delivery. Known values are: - "Allow", "Deny". + "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.media.models.DefaultAction :ivar ip_allow_list: The IP allow list for access control in Key Delivery. If the default action is set to 'Allow', the IP allow list must be empty. @@ -269,8 +261,8 @@ class AccessControl(msrest.serialization.Model): """ _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'ip_allow_list': {'key': 'ipAllowList', 'type': '[str]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "ip_allow_list": {"key": "ipAllowList", "type": "[str]"}, } def __init__( @@ -282,26 +274,26 @@ def __init__( ): """ :keyword default_action: The behavior for IP access control in Key Delivery. Known values are: - "Allow", "Deny". + "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.media.models.DefaultAction :keyword ip_allow_list: The IP allow list for access control in Key Delivery. If the default action is set to 'Allow', the IP allow list must be empty. :paramtype ip_allow_list: list[str] """ - super(AccessControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.ip_allow_list = ip_allow_list -class AccountEncryption(msrest.serialization.Model): +class AccountEncryption(_serialization.Model): """AccountEncryption. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of key used to encrypt the Account Key. Known values are: - "SystemKey", "CustomerKey". + :ivar type: The type of key used to encrypt the Account Key. Required. Known values are: + "SystemKey" and "CustomerKey". :vartype type: str or ~azure.mgmt.media.models.AccountEncryptionKeyType :ivar key_vault_properties: The properties of the key used to encrypt the account. :vartype key_vault_properties: ~azure.mgmt.media.models.KeyVaultProperties @@ -312,15 +304,15 @@ class AccountEncryption(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'status': {'readonly': True}, + "type": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -332,22 +324,22 @@ def __init__( **kwargs ): """ - :keyword type: Required. The type of key used to encrypt the Account Key. Known values are: - "SystemKey", "CustomerKey". + :keyword type: The type of key used to encrypt the Account Key. Required. Known values are: + "SystemKey" and "CustomerKey". :paramtype type: str or ~azure.mgmt.media.models.AccountEncryptionKeyType :keyword key_vault_properties: The properties of the key used to encrypt the account. :paramtype key_vault_properties: ~azure.mgmt.media.models.KeyVaultProperties :keyword identity: The Key Vault identity. :paramtype identity: ~azure.mgmt.media.models.ResourceIdentity """ - super(AccountEncryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.key_vault_properties = key_vault_properties self.identity = identity self.status = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -363,24 +355,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -402,24 +390,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class AccountFilter(ProxyResource): @@ -446,20 +430,20 @@ class AccountFilter(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"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'}, - 'presentation_time_range': {'key': 'properties.presentationTimeRange', 'type': 'PresentationTimeRange'}, - 'first_quality': {'key': 'properties.firstQuality', 'type': 'FirstQuality'}, - 'tracks': {'key': 'properties.tracks', 'type': '[FilterTrackSelection]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "presentation_time_range": {"key": "properties.presentationTimeRange", "type": "PresentationTimeRange"}, + "first_quality": {"key": "properties.firstQuality", "type": "FirstQuality"}, + "tracks": {"key": "properties.tracks", "type": "[FilterTrackSelection]"}, } def __init__( @@ -478,14 +462,14 @@ def __init__( :keyword tracks: The tracks selection conditions. :paramtype tracks: list[~azure.mgmt.media.models.FilterTrackSelection] """ - super(AccountFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.presentation_time_range = presentation_time_range self.first_quality = first_quality self.tracks = tracks -class AccountFilterCollection(msrest.serialization.Model): +class AccountFilterCollection(_serialization.Model): """A collection of AccountFilter items. :ivar value: A collection of AccountFilter items. @@ -496,16 +480,12 @@ class AccountFilterCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AccountFilter]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AccountFilter]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.AccountFilter"]] = None, - odata_next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AccountFilter"]] = None, odata_next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of AccountFilter items. @@ -514,12 +494,12 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(AccountFilterCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class AkamaiAccessControl(msrest.serialization.Model): +class AkamaiAccessControl(_serialization.Model): """Akamai access control. :ivar akamai_signature_header_authentication_key_list: authentication key list. @@ -528,13 +508,18 @@ class AkamaiAccessControl(msrest.serialization.Model): """ _attribute_map = { - 'akamai_signature_header_authentication_key_list': {'key': 'akamaiSignatureHeaderAuthenticationKeyList', 'type': '[AkamaiSignatureHeaderAuthenticationKey]'}, + "akamai_signature_header_authentication_key_list": { + "key": "akamaiSignatureHeaderAuthenticationKeyList", + "type": "[AkamaiSignatureHeaderAuthenticationKey]", + }, } def __init__( self, *, - akamai_signature_header_authentication_key_list: Optional[List["_models.AkamaiSignatureHeaderAuthenticationKey"]] = None, + akamai_signature_header_authentication_key_list: Optional[ + List["_models.AkamaiSignatureHeaderAuthenticationKey"] + ] = None, **kwargs ): """ @@ -542,11 +527,11 @@ def __init__( :paramtype akamai_signature_header_authentication_key_list: list[~azure.mgmt.media.models.AkamaiSignatureHeaderAuthenticationKey] """ - super(AkamaiAccessControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.akamai_signature_header_authentication_key_list = akamai_signature_header_authentication_key_list -class AkamaiSignatureHeaderAuthenticationKey(msrest.serialization.Model): +class AkamaiSignatureHeaderAuthenticationKey(_serialization.Model): """Akamai Signature Header authentication key. :ivar identifier: identifier of the key. @@ -558,9 +543,9 @@ class AkamaiSignatureHeaderAuthenticationKey(msrest.serialization.Model): """ _attribute_map = { - 'identifier': {'key': 'identifier', 'type': 'str'}, - 'base64_key': {'key': 'base64Key', 'type': 'str'}, - 'expiration': {'key': 'expiration', 'type': 'iso-8601'}, + "identifier": {"key": "identifier", "type": "str"}, + "base64_key": {"key": "base64Key", "type": "str"}, + "expiration": {"key": "expiration", "type": "iso-8601"}, } def __init__( @@ -579,13 +564,13 @@ def __init__( :keyword expiration: The expiration time of the authentication key. :paramtype expiration: ~datetime.datetime """ - super(AkamaiSignatureHeaderAuthenticationKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.identifier = identifier self.base64_key = base64_key self.expiration = expiration -class ArmStreamingEndpointCapacity(msrest.serialization.Model): +class ArmStreamingEndpointCapacity(_serialization.Model): """The streaming endpoint sku capacity. Variables are only populated by the server, and will be ignored when sending a request. @@ -601,23 +586,18 @@ class ArmStreamingEndpointCapacity(msrest.serialization.Model): """ _validation = { - 'scale_type': {'readonly': True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - 'default': {'key': 'default', 'type': 'int'}, - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, + "scale_type": {"key": "scaleType", "type": "str"}, + "default": {"key": "default", "type": "int"}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, } def __init__( - self, - *, - default: Optional[int] = None, - minimum: Optional[int] = None, - maximum: Optional[int] = None, - **kwargs + self, *, default: Optional[int] = None, minimum: Optional[int] = None, maximum: Optional[int] = None, **kwargs ): """ :keyword default: The streaming endpoint default capacity. @@ -627,14 +607,14 @@ def __init__( :keyword maximum: The streaming endpoint maximum capacity. :paramtype maximum: int """ - super(ArmStreamingEndpointCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.scale_type = None self.default = default self.minimum = minimum self.maximum = maximum -class ArmStreamingEndpointCurrentSku(msrest.serialization.Model): +class ArmStreamingEndpointCurrentSku(_serialization.Model): """The streaming endpoint current sku. Variables are only populated by the server, and will be ignored when sending a request. @@ -646,30 +626,25 @@ class ArmStreamingEndpointCurrentSku(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, capacity: Optional[int] = None, **kwargs): """ :keyword capacity: The streaming endpoint sku capacity. :paramtype capacity: int """ - super(ArmStreamingEndpointCurrentSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.capacity = capacity -class ArmStreamingEndpointSku(msrest.serialization.Model): +class ArmStreamingEndpointSku(_serialization.Model): """The streaming endpoint sku. Variables are only populated by the server, and will be ignored when sending a request. @@ -679,24 +654,20 @@ class ArmStreamingEndpointSku(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ArmStreamingEndpointSku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None -class ArmStreamingEndpointSkuInfo(msrest.serialization.Model): +class ArmStreamingEndpointSkuInfo(_serialization.Model): """ArmStreamingEndpointSkuInfo. :ivar resource_type: @@ -708,9 +679,9 @@ class ArmStreamingEndpointSkuInfo(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'ArmStreamingEndpointCapacity'}, - 'sku': {'key': 'sku', 'type': 'ArmStreamingEndpointSku'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "capacity": {"key": "capacity", "type": "ArmStreamingEndpointCapacity"}, + "sku": {"key": "sku", "type": "ArmStreamingEndpointSku"}, } def __init__( @@ -729,13 +700,13 @@ def __init__( :keyword sku: The streaming endpoint sku. :paramtype sku: ~azure.mgmt.media.models.ArmStreamingEndpointSku """ - super(ArmStreamingEndpointSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.capacity = capacity self.sku = sku -class Asset(ProxyResource): +class Asset(ProxyResource): # pylint: disable=too-many-instance-attributes """An Asset. Variables are only populated by the server, and will be ignored when sending a request. @@ -765,35 +736,35 @@ class Asset(ProxyResource): :ivar storage_account_name: The name of the storage account. :vartype storage_account_name: str :ivar storage_encryption_format: The Asset encryption format. One of None or - MediaStorageEncryption. Known values are: "None", "MediaStorageClientEncryption". + MediaStorageEncryption. Known values are: "None" and "MediaStorageClientEncryption". :vartype storage_encryption_format: str or ~azure.mgmt.media.models.AssetStorageEncryptionFormat """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'asset_id': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, - 'storage_encryption_format': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "asset_id": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"readonly": True}, + "storage_encryption_format": {"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'}, - 'asset_id': {'key': 'properties.assetId', 'type': 'str'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, - 'alternate_id': {'key': 'properties.alternateId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'container': {'key': 'properties.container', 'type': 'str'}, - 'storage_account_name': {'key': 'properties.storageAccountName', 'type': 'str'}, - 'storage_encryption_format': {'key': 'properties.storageEncryptionFormat', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "asset_id": {"key": "properties.assetId", "type": "str"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "alternate_id": {"key": "properties.alternateId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "container": {"key": "properties.container", "type": "str"}, + "storage_account_name": {"key": "properties.storageAccountName", "type": "str"}, + "storage_encryption_format": {"key": "properties.storageEncryptionFormat", "type": "str"}, } def __init__( @@ -815,7 +786,7 @@ def __init__( :keyword storage_account_name: The name of the storage account. :paramtype storage_account_name: str """ - super(Asset, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.asset_id = None self.created = None @@ -827,7 +798,7 @@ def __init__( self.storage_encryption_format = None -class AssetCollection(msrest.serialization.Model): +class AssetCollection(_serialization.Model): """A collection of Asset items. :ivar value: A collection of Asset items. @@ -838,16 +809,12 @@ class AssetCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Asset]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Asset]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.Asset"]] = None, - odata_next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Asset"]] = None, odata_next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of Asset items. @@ -856,12 +823,12 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(AssetCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class AssetContainerSas(msrest.serialization.Model): +class AssetContainerSas(_serialization.Model): """The Asset Storage container SAS URLs. :ivar asset_container_sas_urls: The list of Asset container SAS URLs. @@ -869,24 +836,19 @@ class AssetContainerSas(msrest.serialization.Model): """ _attribute_map = { - 'asset_container_sas_urls': {'key': 'assetContainerSasUrls', 'type': '[str]'}, + "asset_container_sas_urls": {"key": "assetContainerSasUrls", "type": "[str]"}, } - def __init__( - self, - *, - asset_container_sas_urls: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, asset_container_sas_urls: Optional[List[str]] = None, **kwargs): """ :keyword asset_container_sas_urls: The list of Asset container SAS URLs. :paramtype asset_container_sas_urls: list[str] """ - super(AssetContainerSas, self).__init__(**kwargs) + super().__init__(**kwargs) self.asset_container_sas_urls = asset_container_sas_urls -class AssetFileEncryptionMetadata(msrest.serialization.Model): +class AssetFileEncryptionMetadata(_serialization.Model): """The Asset File Storage encryption metadata. All required parameters must be populated in order to send to Azure. @@ -895,18 +857,18 @@ class AssetFileEncryptionMetadata(msrest.serialization.Model): :vartype initialization_vector: str :ivar asset_file_name: The Asset File name. :vartype asset_file_name: str - :ivar asset_file_id: Required. The Asset File Id. + :ivar asset_file_id: The Asset File Id. Required. :vartype asset_file_id: str """ _validation = { - 'asset_file_id': {'required': True}, + "asset_file_id": {"required": True}, } _attribute_map = { - 'initialization_vector': {'key': 'initializationVector', 'type': 'str'}, - 'asset_file_name': {'key': 'assetFileName', 'type': 'str'}, - 'asset_file_id': {'key': 'assetFileId', 'type': 'str'}, + "initialization_vector": {"key": "initializationVector", "type": "str"}, + "asset_file_name": {"key": "assetFileName", "type": "str"}, + "asset_file_id": {"key": "assetFileId", "type": "str"}, } def __init__( @@ -922,10 +884,10 @@ def __init__( :paramtype initialization_vector: str :keyword asset_file_name: The Asset File name. :paramtype asset_file_name: str - :keyword asset_file_id: Required. The Asset File Id. + :keyword asset_file_id: The Asset File Id. Required. :paramtype asset_file_id: str """ - super(AssetFileEncryptionMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.initialization_vector = initialization_vector self.asset_file_name = asset_file_name self.asset_file_id = asset_file_id @@ -955,20 +917,20 @@ class AssetFilter(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"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'}, - 'presentation_time_range': {'key': 'properties.presentationTimeRange', 'type': 'PresentationTimeRange'}, - 'first_quality': {'key': 'properties.firstQuality', 'type': 'FirstQuality'}, - 'tracks': {'key': 'properties.tracks', 'type': '[FilterTrackSelection]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "presentation_time_range": {"key": "properties.presentationTimeRange", "type": "PresentationTimeRange"}, + "first_quality": {"key": "properties.firstQuality", "type": "FirstQuality"}, + "tracks": {"key": "properties.tracks", "type": "[FilterTrackSelection]"}, } def __init__( @@ -987,14 +949,14 @@ def __init__( :keyword tracks: The tracks selection conditions. :paramtype tracks: list[~azure.mgmt.media.models.FilterTrackSelection] """ - super(AssetFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.presentation_time_range = presentation_time_range self.first_quality = first_quality self.tracks = tracks -class AssetFilterCollection(msrest.serialization.Model): +class AssetFilterCollection(_serialization.Model): """A collection of AssetFilter items. :ivar value: A collection of AssetFilter items. @@ -1005,16 +967,12 @@ class AssetFilterCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AssetFilter]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AssetFilter]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.AssetFilter"]] = None, - odata_next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.AssetFilter"]] = None, odata_next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of AssetFilter items. @@ -1023,12 +981,12 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(AssetFilterCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class AssetStreamingLocator(msrest.serialization.Model): +class AssetStreamingLocator(_serialization.Model): """Properties of the Streaming Locator. Variables are only populated by the server, and will be ignored when sending a request. @@ -1053,34 +1011,30 @@ class AssetStreamingLocator(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'asset_name': {'readonly': True}, - 'created': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'streaming_locator_id': {'readonly': True}, - 'streaming_policy_name': {'readonly': True}, - 'default_content_key_policy_name': {'readonly': True}, + "name": {"readonly": True}, + "asset_name": {"readonly": True}, + "created": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "streaming_locator_id": {"readonly": True}, + "streaming_policy_name": {"readonly": True}, + "default_content_key_policy_name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'asset_name': {'key': 'assetName', 'type': 'str'}, - 'created': {'key': 'created', 'type': 'iso-8601'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'streaming_locator_id': {'key': 'streamingLocatorId', 'type': 'str'}, - 'streaming_policy_name': {'key': 'streamingPolicyName', 'type': 'str'}, - 'default_content_key_policy_name': {'key': 'defaultContentKeyPolicyName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "asset_name": {"key": "assetName", "type": "str"}, + "created": {"key": "created", "type": "iso-8601"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "streaming_locator_id": {"key": "streamingLocatorId", "type": "str"}, + "streaming_policy_name": {"key": "streamingPolicyName", "type": "str"}, + "default_content_key_policy_name": {"key": "defaultContentKeyPolicyName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AssetStreamingLocator, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.asset_name = None self.created = None @@ -1107,41 +1061,36 @@ class AssetTrack(ProxyResource): :ivar track: Detailed information about a track in the asset. :vartype track: ~azure.mgmt.media.models.TrackBase :ivar provisioning_state: Provisioning state of the asset track. Known values are: "Failed", - "InProgress", "Succeeded". + "InProgress", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.media.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'track': {'key': 'properties.track', 'type': 'TrackBase'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "track": {"key": "properties.track", "type": "TrackBase"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__( - self, - *, - track: Optional["_models.TrackBase"] = None, - **kwargs - ): + def __init__(self, *, track: Optional["_models.TrackBase"] = None, **kwargs): """ :keyword track: Detailed information about a track in the asset. :paramtype track: ~azure.mgmt.media.models.TrackBase """ - super(AssetTrack, self).__init__(**kwargs) + super().__init__(**kwargs) self.track = track self.provisioning_state = None -class AssetTrackCollection(msrest.serialization.Model): +class AssetTrackCollection(_serialization.Model): """A collection of AssetTrack items. :ivar value: A collection of AssetTrack items. @@ -1149,29 +1098,24 @@ class AssetTrackCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AssetTrack]'}, + "value": {"key": "value", "type": "[AssetTrack]"}, } - def __init__( - self, - *, - value: Optional[List["_models.AssetTrack"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AssetTrack"]] = None, **kwargs): """ :keyword value: A collection of AssetTrack items. :paramtype value: list[~azure.mgmt.media.models.AssetTrack] """ - super(AssetTrackCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class AssetTrackOperationStatus(msrest.serialization.Model): +class AssetTrackOperationStatus(_serialization.Model): """Status of asset track operation. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Operation identifier. + :ivar name: Operation identifier. Required. :vartype name: str :ivar id: Operation resource ID. :vartype id: str @@ -1179,24 +1123,24 @@ class AssetTrackOperationStatus(msrest.serialization.Model): :vartype start_time: ~datetime.datetime :ivar end_time: Operation end time. :vartype end_time: ~datetime.datetime - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar error: The error detail. :vartype error: ~azure.mgmt.media.models.ErrorDetail """ _validation = { - 'name': {'required': True}, - 'status': {'required': True}, + "name": {"required": True}, + "status": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( @@ -1204,14 +1148,14 @@ def __init__( *, name: str, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ - :keyword name: Required. Operation identifier. + :keyword name: Operation identifier. Required. :paramtype name: str :keyword id: Operation resource ID. :paramtype id: str @@ -1219,12 +1163,12 @@ def __init__( :paramtype start_time: ~datetime.datetime :keyword end_time: Operation end time. :paramtype end_time: ~datetime.datetime - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword error: The error detail. :paramtype error: ~azure.mgmt.media.models.ErrorDetail """ - super(AssetTrackOperationStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.id = id self.start_time = start_time @@ -1233,49 +1177,91 @@ def __init__( self.error = error -class Preset(msrest.serialization.Model): +class AsyncOperationResult(_serialization.Model): + """The status of an async operation. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.media.models.ErrorDetail + :ivar name: Operation Id of the async operation. + :vartype name: str + :ivar status: Operation status of the async operation. Known values are: "Succeeded", "Failed", + and "InProgress". + :vartype status: str or ~azure.mgmt.media.models.AsyncOperationStatus + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + name: Optional[str] = None, + status: Optional[Union[str, "_models.AsyncOperationStatus"]] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.media.models.ErrorDetail + :keyword name: Operation Id of the async operation. + :paramtype name: str + :keyword status: Operation status of the async operation. Known values are: "Succeeded", + "Failed", and "InProgress". + :paramtype status: str or ~azure.mgmt.media.models.AsyncOperationStatus + """ + super().__init__(**kwargs) + self.error = error + self.name = name + self.status = status + + +class Preset(_serialization.Model): """Base type for all Presets, which define the recipe or instructions on how the input media files should be processed. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AudioAnalyzerPreset, BuiltInStandardEncoderPreset, FaceDetectorPreset, StandardEncoderPreset. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AudioAnalyzerPreset, BuiltInStandardEncoderPreset, FaceDetectorPreset, StandardEncoderPreset All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.AudioAnalyzerPreset': 'AudioAnalyzerPreset', '#Microsoft.Media.BuiltInStandardEncoderPreset': 'BuiltInStandardEncoderPreset', '#Microsoft.Media.FaceDetectorPreset': 'FaceDetectorPreset', '#Microsoft.Media.StandardEncoderPreset': 'StandardEncoderPreset'} + "odata_type": { + "#Microsoft.Media.AudioAnalyzerPreset": "AudioAnalyzerPreset", + "#Microsoft.Media.BuiltInStandardEncoderPreset": "BuiltInStandardEncoderPreset", + "#Microsoft.Media.FaceDetectorPreset": "FaceDetectorPreset", + "#Microsoft.Media.StandardEncoderPreset": "StandardEncoderPreset", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(Preset, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] class AudioAnalyzerPreset(Preset): """The Audio Analyzer preset applies a pre-defined set of AI-based analysis operations, including speech transcription. Currently, the preset supports processing of content with a single audio track. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: VideoAnalyzerPreset. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VideoAnalyzerPreset All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar audio_language: The language for the audio payload in the input using the BCP-47 format of 'language tag-region' (e.g: 'en-US'). If you know the language of your content, it is @@ -1290,7 +1276,7 @@ class AudioAnalyzerPreset(Preset): https://go.microsoft.com/fwlink/?linkid=2109463. :vartype audio_language: str :ivar mode: Determines the set of audio analysis operations to be performed. If unspecified, - the Standard AudioAnalysisMode would be chosen. Known values are: "Standard", "Basic". + the Standard AudioAnalysisMode would be chosen. Known values are: "Standard" and "Basic". :vartype mode: str or ~azure.mgmt.media.models.AudioAnalysisMode :ivar experimental_options: Dictionary containing key value pairs for parameters not exposed in the preset itself. @@ -1298,19 +1284,17 @@ class AudioAnalyzerPreset(Preset): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'audio_language': {'key': 'audioLanguage', 'type': 'str'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'experimental_options': {'key': 'experimentalOptions', 'type': '{str}'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "audio_language": {"key": "audioLanguage", "type": "str"}, + "mode": {"key": "mode", "type": "str"}, + "experimental_options": {"key": "experimentalOptions", "type": "{str}"}, } - _subtype_map = { - 'odata_type': {'#Microsoft.Media.VideoAnalyzerPreset': 'VideoAnalyzerPreset'} - } + _subtype_map = {"odata_type": {"#Microsoft.Media.VideoAnalyzerPreset": "VideoAnalyzerPreset"}} def __init__( self, @@ -1334,33 +1318,34 @@ def __init__( https://go.microsoft.com/fwlink/?linkid=2109463. :paramtype audio_language: str :keyword mode: Determines the set of audio analysis operations to be performed. If unspecified, - the Standard AudioAnalysisMode would be chosen. Known values are: "Standard", "Basic". + the Standard AudioAnalysisMode would be chosen. Known values are: "Standard" and "Basic". :paramtype mode: str or ~azure.mgmt.media.models.AudioAnalysisMode :keyword experimental_options: Dictionary containing key value pairs for parameters not exposed in the preset itself. :paramtype experimental_options: dict[str, str] """ - super(AudioAnalyzerPreset, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.AudioAnalyzerPreset' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.AudioAnalyzerPreset" # type: str self.audio_language = audio_language self.mode = mode self.experimental_options = experimental_options -class Overlay(msrest.serialization.Model): +class Overlay(_serialization.Model): """Base type for all overlays - image, audio or video. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AudioOverlay, VideoOverlay. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AudioOverlay, VideoOverlay All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar input_label: Required. The label of the job input which is to be used as an overlay. The - Input must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP - format, or an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See + :ivar input_label: The label of the job input which is to be used as an overlay. The Input must + specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP format, or an + audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See https://aka.ms/mesformats for the complete list of supported audio and video file formats. + Required. :vartype input_label: str :ivar start: The start position, with reference to the input video, at which the overlay starts. The value should be in ISO 8601 format. For example, PT05S to start the overlay at 5 @@ -1388,22 +1373,22 @@ class Overlay(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, - 'input_label': {'required': True}, + "odata_type": {"required": True}, + "input_label": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'input_label': {'key': 'inputLabel', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'duration'}, - 'end': {'key': 'end', 'type': 'duration'}, - 'fade_in_duration': {'key': 'fadeInDuration', 'type': 'duration'}, - 'fade_out_duration': {'key': 'fadeOutDuration', 'type': 'duration'}, - 'audio_gain_level': {'key': 'audioGainLevel', 'type': 'float'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "input_label": {"key": "inputLabel", "type": "str"}, + "start": {"key": "start", "type": "duration"}, + "end": {"key": "end", "type": "duration"}, + "fade_in_duration": {"key": "fadeInDuration", "type": "duration"}, + "fade_out_duration": {"key": "fadeOutDuration", "type": "duration"}, + "audio_gain_level": {"key": "audioGainLevel", "type": "float"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.AudioOverlay': 'AudioOverlay', '#Microsoft.Media.VideoOverlay': 'VideoOverlay'} + "odata_type": {"#Microsoft.Media.AudioOverlay": "AudioOverlay", "#Microsoft.Media.VideoOverlay": "VideoOverlay"} } def __init__( @@ -1418,10 +1403,11 @@ def __init__( **kwargs ): """ - :keyword input_label: Required. The label of the job input which is to be used as an overlay. - The Input must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP - format, or an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See + :keyword input_label: The label of the job input which is to be used as an overlay. The Input + must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP format, or + an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See https://aka.ms/mesformats for the complete list of supported audio and video file formats. + Required. :paramtype input_label: str :keyword start: The start position, with reference to the input video, at which the overlay starts. The value should be in ISO 8601 format. For example, PT05S to start the overlay at 5 @@ -1447,7 +1433,7 @@ def __init__( range [0, 1.0]. The default is 1.0. :paramtype audio_gain_level: float """ - super(Overlay, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.input_label = input_label self.start = start @@ -1462,12 +1448,13 @@ class AudioOverlay(Overlay): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar input_label: Required. The label of the job input which is to be used as an overlay. The - Input must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP - format, or an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See + :ivar input_label: The label of the job input which is to be used as an overlay. The Input must + specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP format, or an + audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See https://aka.ms/mesformats for the complete list of supported audio and video file formats. + Required. :vartype input_label: str :ivar start: The start position, with reference to the input video, at which the overlay starts. The value should be in ISO 8601 format. For example, PT05S to start the overlay at 5 @@ -1495,18 +1482,18 @@ class AudioOverlay(Overlay): """ _validation = { - 'odata_type': {'required': True}, - 'input_label': {'required': True}, + "odata_type": {"required": True}, + "input_label": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'input_label': {'key': 'inputLabel', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'duration'}, - 'end': {'key': 'end', 'type': 'duration'}, - 'fade_in_duration': {'key': 'fadeInDuration', 'type': 'duration'}, - 'fade_out_duration': {'key': 'fadeOutDuration', 'type': 'duration'}, - 'audio_gain_level': {'key': 'audioGainLevel', 'type': 'float'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "input_label": {"key": "inputLabel", "type": "str"}, + "start": {"key": "start", "type": "duration"}, + "end": {"key": "end", "type": "duration"}, + "fade_in_duration": {"key": "fadeInDuration", "type": "duration"}, + "fade_out_duration": {"key": "fadeOutDuration", "type": "duration"}, + "audio_gain_level": {"key": "audioGainLevel", "type": "float"}, } def __init__( @@ -1521,10 +1508,11 @@ def __init__( **kwargs ): """ - :keyword input_label: Required. The label of the job input which is to be used as an overlay. - The Input must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP - format, or an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See + :keyword input_label: The label of the job input which is to be used as an overlay. The Input + must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP format, or + an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See https://aka.ms/mesformats for the complete list of supported audio and video file formats. + Required. :paramtype input_label: str :keyword start: The start position, with reference to the input video, at which the overlay starts. The value should be in ISO 8601 format. For example, PT05S to start the overlay at 5 @@ -1550,150 +1538,209 @@ def __init__( range [0, 1.0]. The default is 1.0. :paramtype audio_gain_level: float """ - super(AudioOverlay, self).__init__(input_label=input_label, start=start, end=end, fade_in_duration=fade_in_duration, fade_out_duration=fade_out_duration, audio_gain_level=audio_gain_level, **kwargs) - self.odata_type = '#Microsoft.Media.AudioOverlay' # type: str + super().__init__( + input_label=input_label, + start=start, + end=end, + fade_in_duration=fade_in_duration, + fade_out_duration=fade_out_duration, + audio_gain_level=audio_gain_level, + **kwargs + ) + self.odata_type = "#Microsoft.Media.AudioOverlay" # type: str -class TrackBase(msrest.serialization.Model): +class TrackBase(_serialization.Model): """Base type for concrete track types. A derived type must be used to represent the Track. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AudioTrack, TextTrack, VideoTrack. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AudioTrack, TextTrack, VideoTrack All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.AudioTrack': 'AudioTrack', '#Microsoft.Media.TextTrack': 'TextTrack', '#Microsoft.Media.VideoTrack': 'VideoTrack'} + "odata_type": { + "#Microsoft.Media.AudioTrack": "AudioTrack", + "#Microsoft.Media.TextTrack": "TextTrack", + "#Microsoft.Media.VideoTrack": "VideoTrack", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(TrackBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] class AudioTrack(TrackBase): """Represents an audio track in the asset. + Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str + :ivar file_name: The file name to the source file. This file is located in the storage + container of the asset. + :vartype file_name: str + :ivar display_name: The display name of the audio track on a video player. In HLS, this maps to + the NAME attribute of EXT-X-MEDIA. + :vartype display_name: str + :ivar language_code: The RFC5646 language code for the audio track. + :vartype language_code: str + :ivar hls_settings: The HLS specific setting for the audio track. + :vartype hls_settings: ~azure.mgmt.media.models.HlsSettings + :ivar dash_settings: The DASH specific setting for the audio track. + :vartype dash_settings: ~azure.mgmt.media.models.DashSettings + :ivar mpeg4_track_id: The MPEG-4 audio track ID for the audio track. + :vartype mpeg4_track_id: int + :ivar bit_rate: The stream bit rate for the audio track. + :vartype bit_rate: int """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, + "bit_rate": {"readonly": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "file_name": {"key": "fileName", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "language_code": {"key": "languageCode", "type": "str"}, + "hls_settings": {"key": "hlsSettings", "type": "HlsSettings"}, + "dash_settings": {"key": "dashSettings", "type": "DashSettings"}, + "mpeg4_track_id": {"key": "mpeg4TrackId", "type": "int"}, + "bit_rate": {"key": "bitRate", "type": "int"}, } def __init__( self, + *, + file_name: Optional[str] = None, + display_name: Optional[str] = None, + language_code: Optional[str] = None, + hls_settings: Optional["_models.HlsSettings"] = None, + dash_settings: Optional["_models.DashSettings"] = None, + mpeg4_track_id: Optional[int] = None, **kwargs ): """ + :keyword file_name: The file name to the source file. This file is located in the storage + container of the asset. + :paramtype file_name: str + :keyword display_name: The display name of the audio track on a video player. In HLS, this maps + to the NAME attribute of EXT-X-MEDIA. + :paramtype display_name: str + :keyword language_code: The RFC5646 language code for the audio track. + :paramtype language_code: str + :keyword hls_settings: The HLS specific setting for the audio track. + :paramtype hls_settings: ~azure.mgmt.media.models.HlsSettings + :keyword dash_settings: The DASH specific setting for the audio track. + :paramtype dash_settings: ~azure.mgmt.media.models.DashSettings + :keyword mpeg4_track_id: The MPEG-4 audio track ID for the audio track. + :paramtype mpeg4_track_id: int """ - super(AudioTrack, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.AudioTrack' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.AudioTrack" # type: str + self.file_name = file_name + self.display_name = display_name + self.language_code = language_code + self.hls_settings = hls_settings + self.dash_settings = dash_settings + self.mpeg4_track_id = mpeg4_track_id + self.bit_rate = None -class TrackDescriptor(msrest.serialization.Model): +class TrackDescriptor(_serialization.Model): """Base type for all TrackDescriptor types, which define the metadata and selection for tracks that should be processed by a Job. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AudioTrackDescriptor, VideoTrackDescriptor. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AudioTrackDescriptor, VideoTrackDescriptor All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.AudioTrackDescriptor': 'AudioTrackDescriptor', '#Microsoft.Media.VideoTrackDescriptor': 'VideoTrackDescriptor'} + "odata_type": { + "#Microsoft.Media.AudioTrackDescriptor": "AudioTrackDescriptor", + "#Microsoft.Media.VideoTrackDescriptor": "VideoTrackDescriptor", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(TrackDescriptor, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] class AudioTrackDescriptor(TrackDescriptor): """A TrackSelection to select audio tracks. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SelectAudioTrackByAttribute, SelectAudioTrackById. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SelectAudioTrackByAttribute, SelectAudioTrackById All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar channel_mapping: Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. Known values are: "FrontLeft", - "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", + "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", and "StereoRight". :vartype channel_mapping: str or ~azure.mgmt.media.models.ChannelMapping """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'channel_mapping': {'key': 'channelMapping', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "channel_mapping": {"key": "channelMapping", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.SelectAudioTrackByAttribute': 'SelectAudioTrackByAttribute', '#Microsoft.Media.SelectAudioTrackById': 'SelectAudioTrackById'} + "odata_type": { + "#Microsoft.Media.SelectAudioTrackByAttribute": "SelectAudioTrackByAttribute", + "#Microsoft.Media.SelectAudioTrackById": "SelectAudioTrackById", + } } - def __init__( - self, - *, - channel_mapping: Optional[Union[str, "_models.ChannelMapping"]] = None, - **kwargs - ): + def __init__(self, *, channel_mapping: Optional[Union[str, "_models.ChannelMapping"]] = None, **kwargs): """ :keyword channel_mapping: Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. Known values are: "FrontLeft", - "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", + "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", and "StereoRight". :paramtype channel_mapping: str or ~azure.mgmt.media.models.ChannelMapping """ - super(AudioTrackDescriptor, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.AudioTrackDescriptor' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.AudioTrackDescriptor" # type: str self.channel_mapping = channel_mapping @@ -1702,30 +1749,30 @@ class BuiltInStandardEncoderPreset(Preset): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar configurations: Optional configuration settings for encoder. Configurations is only supported for ContentAwareEncoding and H265ContentAwareEncoding BuiltInStandardEncoderPreset. :vartype configurations: ~azure.mgmt.media.models.PresetConfigurations - :ivar preset_name: Required. The built-in preset to be used for encoding videos. Known values + :ivar preset_name: The built-in preset to be used for encoding videos. Required. Known values are: "H264SingleBitrateSD", "H264SingleBitrate720p", "H264SingleBitrate1080p", "AdaptiveStreaming", "AACGoodQualityAudio", "ContentAwareEncodingExperimental", "ContentAwareEncoding", "CopyAllBitrateNonInterleaved", "H264MultipleBitrate1080p", "H264MultipleBitrate720p", "H264MultipleBitrateSD", "H265ContentAwareEncoding", - "H265AdaptiveStreaming", "H265SingleBitrate720p", "H265SingleBitrate1080p", + "H265AdaptiveStreaming", "H265SingleBitrate720p", "H265SingleBitrate1080p", and "H265SingleBitrate4K". :vartype preset_name: str or ~azure.mgmt.media.models.EncoderNamedPreset """ _validation = { - 'odata_type': {'required': True}, - 'preset_name': {'required': True}, + "odata_type": {"required": True}, + "preset_name": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'configurations': {'key': 'configurations', 'type': 'PresetConfigurations'}, - 'preset_name': {'key': 'presetName', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "configurations": {"key": "configurations", "type": "PresetConfigurations"}, + "preset_name": {"key": "presetName", "type": "str"}, } def __init__( @@ -1739,22 +1786,22 @@ def __init__( :keyword configurations: Optional configuration settings for encoder. Configurations is only supported for ContentAwareEncoding and H265ContentAwareEncoding BuiltInStandardEncoderPreset. :paramtype configurations: ~azure.mgmt.media.models.PresetConfigurations - :keyword preset_name: Required. The built-in preset to be used for encoding videos. Known + :keyword preset_name: The built-in preset to be used for encoding videos. Required. Known values are: "H264SingleBitrateSD", "H264SingleBitrate720p", "H264SingleBitrate1080p", "AdaptiveStreaming", "AACGoodQualityAudio", "ContentAwareEncodingExperimental", "ContentAwareEncoding", "CopyAllBitrateNonInterleaved", "H264MultipleBitrate1080p", "H264MultipleBitrate720p", "H264MultipleBitrateSD", "H265ContentAwareEncoding", - "H265AdaptiveStreaming", "H265SingleBitrate720p", "H265SingleBitrate1080p", + "H265AdaptiveStreaming", "H265SingleBitrate720p", "H265SingleBitrate1080p", and "H265SingleBitrate4K". :paramtype preset_name: str or ~azure.mgmt.media.models.EncoderNamedPreset """ - super(BuiltInStandardEncoderPreset, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.BuiltInStandardEncoderPreset' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.BuiltInStandardEncoderPreset" # type: str self.configurations = configurations self.preset_name = preset_name -class CbcsDrmConfiguration(msrest.serialization.Model): +class CbcsDrmConfiguration(_serialization.Model): """Class to specify DRM configurations of CommonEncryptionCbcs scheme in Streaming Policy. :ivar fair_play: FairPlay configurations. @@ -1766,9 +1813,9 @@ class CbcsDrmConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'fair_play': {'key': 'fairPlay', 'type': 'StreamingPolicyFairPlayConfiguration'}, - 'play_ready': {'key': 'playReady', 'type': 'StreamingPolicyPlayReadyConfiguration'}, - 'widevine': {'key': 'widevine', 'type': 'StreamingPolicyWidevineConfiguration'}, + "fair_play": {"key": "fairPlay", "type": "StreamingPolicyFairPlayConfiguration"}, + "play_ready": {"key": "playReady", "type": "StreamingPolicyPlayReadyConfiguration"}, + "widevine": {"key": "widevine", "type": "StreamingPolicyWidevineConfiguration"}, } def __init__( @@ -1787,13 +1834,13 @@ def __init__( :keyword widevine: Widevine configurations. :paramtype widevine: ~azure.mgmt.media.models.StreamingPolicyWidevineConfiguration """ - super(CbcsDrmConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.fair_play = fair_play self.play_ready = play_ready self.widevine = widevine -class CencDrmConfiguration(msrest.serialization.Model): +class CencDrmConfiguration(_serialization.Model): """Class to specify DRM configurations of CommonEncryptionCenc scheme in Streaming Policy. :ivar play_ready: PlayReady configurations. @@ -1803,8 +1850,8 @@ class CencDrmConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'play_ready': {'key': 'playReady', 'type': 'StreamingPolicyPlayReadyConfiguration'}, - 'widevine': {'key': 'widevine', 'type': 'StreamingPolicyWidevineConfiguration'}, + "play_ready": {"key": "playReady", "type": "StreamingPolicyPlayReadyConfiguration"}, + "widevine": {"key": "widevine", "type": "StreamingPolicyWidevineConfiguration"}, } def __init__( @@ -1820,12 +1867,12 @@ def __init__( :keyword widevine: Widevine configurations. :paramtype widevine: ~azure.mgmt.media.models.StreamingPolicyWidevineConfiguration """ - super(CencDrmConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.play_ready = play_ready self.widevine = widevine -class CheckNameAvailabilityInput(msrest.serialization.Model): +class CheckNameAvailabilityInput(_serialization.Model): """The input to the check name availability request. :ivar name: The account name. @@ -1835,29 +1882,53 @@ class CheckNameAvailabilityInput(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): """ :keyword name: The account name. :paramtype name: str :keyword type: The account type. For a Media Services account, this should be 'MediaServices'. :paramtype type: str """ - super(CheckNameAvailabilityInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class CommonEncryptionCbcs(msrest.serialization.Model): +class ClearKeyEncryptionConfiguration(_serialization.Model): + """Class to specify ClearKey configuration of common encryption schemes in Streaming Policy. + + :ivar custom_keys_acquisition_url_template: Template for the URL of the custom service + delivering content keys to end user players. Not required when using Azure Media Services for + issuing licenses. The template supports replaceable tokens that the service will update at + runtime with the value specific to the request. The currently supported token value is + {AlternativeMediaId}, which is replaced with the value of + StreamingLocatorId.AlternativeMediaId. + :vartype custom_keys_acquisition_url_template: str + """ + + _attribute_map = { + "custom_keys_acquisition_url_template": {"key": "customKeysAcquisitionUrlTemplate", "type": "str"}, + } + + def __init__(self, *, custom_keys_acquisition_url_template: Optional[str] = None, **kwargs): + """ + :keyword custom_keys_acquisition_url_template: Template for the URL of the custom service + delivering content keys to end user players. Not required when using Azure Media Services for + issuing licenses. The template supports replaceable tokens that the service will update at + runtime with the value specific to the request. The currently supported token value is + {AlternativeMediaId}, which is replaced with the value of + StreamingLocatorId.AlternativeMediaId. + :paramtype custom_keys_acquisition_url_template: str + """ + super().__init__(**kwargs) + self.custom_keys_acquisition_url_template = custom_keys_acquisition_url_template + + +class CommonEncryptionCbcs(_serialization.Model): """Class for CommonEncryptionCbcs encryption scheme. :ivar enabled_protocols: Representing supported protocols. @@ -1869,13 +1940,21 @@ class CommonEncryptionCbcs(msrest.serialization.Model): :vartype content_keys: ~azure.mgmt.media.models.StreamingPolicyContentKeys :ivar drm: Configuration of DRMs for current encryption scheme. :vartype drm: ~azure.mgmt.media.models.CbcsDrmConfiguration + :ivar clear_key_encryption_configuration: Optional configuration supporting ClearKey in + CommonEncryptionCbcs encryption scheme. + :vartype clear_key_encryption_configuration: + ~azure.mgmt.media.models.ClearKeyEncryptionConfiguration """ _attribute_map = { - 'enabled_protocols': {'key': 'enabledProtocols', 'type': 'EnabledProtocols'}, - 'clear_tracks': {'key': 'clearTracks', 'type': '[TrackSelection]'}, - 'content_keys': {'key': 'contentKeys', 'type': 'StreamingPolicyContentKeys'}, - 'drm': {'key': 'drm', 'type': 'CbcsDrmConfiguration'}, + "enabled_protocols": {"key": "enabledProtocols", "type": "EnabledProtocols"}, + "clear_tracks": {"key": "clearTracks", "type": "[TrackSelection]"}, + "content_keys": {"key": "contentKeys", "type": "StreamingPolicyContentKeys"}, + "drm": {"key": "drm", "type": "CbcsDrmConfiguration"}, + "clear_key_encryption_configuration": { + "key": "clearKeyEncryptionConfiguration", + "type": "ClearKeyEncryptionConfiguration", + }, } def __init__( @@ -1885,6 +1964,7 @@ def __init__( clear_tracks: Optional[List["_models.TrackSelection"]] = None, content_keys: Optional["_models.StreamingPolicyContentKeys"] = None, drm: Optional["_models.CbcsDrmConfiguration"] = None, + clear_key_encryption_configuration: Optional["_models.ClearKeyEncryptionConfiguration"] = None, **kwargs ): """ @@ -1897,15 +1977,20 @@ def __init__( :paramtype content_keys: ~azure.mgmt.media.models.StreamingPolicyContentKeys :keyword drm: Configuration of DRMs for current encryption scheme. :paramtype drm: ~azure.mgmt.media.models.CbcsDrmConfiguration + :keyword clear_key_encryption_configuration: Optional configuration supporting ClearKey in + CommonEncryptionCbcs encryption scheme. + :paramtype clear_key_encryption_configuration: + ~azure.mgmt.media.models.ClearKeyEncryptionConfiguration """ - super(CommonEncryptionCbcs, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled_protocols = enabled_protocols self.clear_tracks = clear_tracks self.content_keys = content_keys self.drm = drm + self.clear_key_encryption_configuration = clear_key_encryption_configuration -class CommonEncryptionCenc(msrest.serialization.Model): +class CommonEncryptionCenc(_serialization.Model): """Class for envelope encryption scheme. :ivar enabled_protocols: Representing supported protocols. @@ -1917,13 +2002,21 @@ class CommonEncryptionCenc(msrest.serialization.Model): :vartype content_keys: ~azure.mgmt.media.models.StreamingPolicyContentKeys :ivar drm: Configuration of DRMs for CommonEncryptionCenc encryption scheme. :vartype drm: ~azure.mgmt.media.models.CencDrmConfiguration + :ivar clear_key_encryption_configuration: Optional configuration supporting ClearKey in + CommonEncryptionCenc encryption scheme. + :vartype clear_key_encryption_configuration: + ~azure.mgmt.media.models.ClearKeyEncryptionConfiguration """ _attribute_map = { - 'enabled_protocols': {'key': 'enabledProtocols', 'type': 'EnabledProtocols'}, - 'clear_tracks': {'key': 'clearTracks', 'type': '[TrackSelection]'}, - 'content_keys': {'key': 'contentKeys', 'type': 'StreamingPolicyContentKeys'}, - 'drm': {'key': 'drm', 'type': 'CencDrmConfiguration'}, + "enabled_protocols": {"key": "enabledProtocols", "type": "EnabledProtocols"}, + "clear_tracks": {"key": "clearTracks", "type": "[TrackSelection]"}, + "content_keys": {"key": "contentKeys", "type": "StreamingPolicyContentKeys"}, + "drm": {"key": "drm", "type": "CencDrmConfiguration"}, + "clear_key_encryption_configuration": { + "key": "clearKeyEncryptionConfiguration", + "type": "ClearKeyEncryptionConfiguration", + }, } def __init__( @@ -1933,6 +2026,7 @@ def __init__( clear_tracks: Optional[List["_models.TrackSelection"]] = None, content_keys: Optional["_models.StreamingPolicyContentKeys"] = None, drm: Optional["_models.CencDrmConfiguration"] = None, + clear_key_encryption_configuration: Optional["_models.ClearKeyEncryptionConfiguration"] = None, **kwargs ): """ @@ -1945,12 +2039,17 @@ def __init__( :paramtype content_keys: ~azure.mgmt.media.models.StreamingPolicyContentKeys :keyword drm: Configuration of DRMs for CommonEncryptionCenc encryption scheme. :paramtype drm: ~azure.mgmt.media.models.CencDrmConfiguration + :keyword clear_key_encryption_configuration: Optional configuration supporting ClearKey in + CommonEncryptionCenc encryption scheme. + :paramtype clear_key_encryption_configuration: + ~azure.mgmt.media.models.ClearKeyEncryptionConfiguration """ - super(CommonEncryptionCenc, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled_protocols = enabled_protocols self.clear_tracks = clear_tracks self.content_keys = content_keys self.drm = drm + self.clear_key_encryption_configuration = clear_key_encryption_configuration class ContentKeyPolicy(ProxyResource): @@ -1981,25 +2080,25 @@ class ContentKeyPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "policy_id": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"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'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'options': {'key': 'properties.options', 'type': '[ContentKeyPolicyOption]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "description": {"key": "properties.description", "type": "str"}, + "options": {"key": "properties.options", "type": "[ContentKeyPolicyOption]"}, } def __init__( @@ -2015,7 +2114,7 @@ def __init__( :keyword options: The Key Policy options. :paramtype options: list[~azure.mgmt.media.models.ContentKeyPolicyOption] """ - super(ContentKeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.policy_id = None self.created = None @@ -2024,37 +2123,41 @@ def __init__( self.options = options -class ContentKeyPolicyConfiguration(msrest.serialization.Model): +class ContentKeyPolicyConfiguration(_serialization.Model): """Base class for Content Key Policy configuration. A derived class must be used to create a configuration. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentKeyPolicyClearKeyConfiguration, ContentKeyPolicyFairPlayConfiguration, ContentKeyPolicyPlayReadyConfiguration, ContentKeyPolicyUnknownConfiguration, ContentKeyPolicyWidevineConfiguration. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentKeyPolicyClearKeyConfiguration, ContentKeyPolicyFairPlayConfiguration, + ContentKeyPolicyPlayReadyConfiguration, ContentKeyPolicyUnknownConfiguration, + ContentKeyPolicyWidevineConfiguration All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration': 'ContentKeyPolicyClearKeyConfiguration', '#Microsoft.Media.ContentKeyPolicyFairPlayConfiguration': 'ContentKeyPolicyFairPlayConfiguration', '#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration': 'ContentKeyPolicyPlayReadyConfiguration', '#Microsoft.Media.ContentKeyPolicyUnknownConfiguration': 'ContentKeyPolicyUnknownConfiguration', '#Microsoft.Media.ContentKeyPolicyWidevineConfiguration': 'ContentKeyPolicyWidevineConfiguration'} - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyConfiguration, self).__init__(**kwargs) + "odata_type": { + "#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration": "ContentKeyPolicyClearKeyConfiguration", + "#Microsoft.Media.ContentKeyPolicyFairPlayConfiguration": "ContentKeyPolicyFairPlayConfiguration", + "#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration": "ContentKeyPolicyPlayReadyConfiguration", + "#Microsoft.Media.ContentKeyPolicyUnknownConfiguration": "ContentKeyPolicyUnknownConfiguration", + "#Microsoft.Media.ContentKeyPolicyWidevineConfiguration": "ContentKeyPolicyWidevineConfiguration", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -2063,29 +2166,25 @@ class ContentKeyPolicyClearKeyConfiguration(ContentKeyPolicyConfiguration): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyClearKeyConfiguration, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration" # type: str -class ContentKeyPolicyCollection(msrest.serialization.Model): +class ContentKeyPolicyCollection(_serialization.Model): """A collection of ContentKeyPolicy items. :ivar value: A collection of ContentKeyPolicy items. @@ -2096,8 +2195,8 @@ class ContentKeyPolicyCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ContentKeyPolicy]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ContentKeyPolicy]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( @@ -2114,7 +2213,7 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(ContentKeyPolicyCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link @@ -2124,50 +2223,53 @@ class ContentKeyPolicyFairPlayConfiguration(ContentKeyPolicyConfiguration): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar ask: Required. The key that must be used as FairPlay Application Secret key. - :vartype ask: bytearray - :ivar fair_play_pfx_password: Required. The password encrypting FairPlay certificate in PKCS 12 - (pfx) format. + :ivar ask: The key that must be used as FairPlay Application Secret key. Required. + :vartype ask: bytes + :ivar fair_play_pfx_password: The password encrypting FairPlay certificate in PKCS 12 (pfx) + format. Required. :vartype fair_play_pfx_password: str - :ivar fair_play_pfx: Required. The Base64 representation of FairPlay certificate in PKCS 12 - (pfx) format (including private key). + :ivar fair_play_pfx: The Base64 representation of FairPlay certificate in PKCS 12 (pfx) format + (including private key). Required. :vartype fair_play_pfx: str - :ivar rental_and_lease_key_type: Required. The rental and lease key type. Known values are: - "Unknown", "Undefined", "DualExpiry", "PersistentUnlimited", "PersistentLimited". + :ivar rental_and_lease_key_type: The rental and lease key type. Required. Known values are: + "Unknown", "Undefined", "DualExpiry", "PersistentUnlimited", and "PersistentLimited". :vartype rental_and_lease_key_type: str or ~azure.mgmt.media.models.ContentKeyPolicyFairPlayRentalAndLeaseKeyType - :ivar rental_duration: Required. The rental duration. Must be greater than or equal to 0. - :vartype rental_duration: long + :ivar rental_duration: The rental duration. Must be greater than or equal to 0. Required. + :vartype rental_duration: int :ivar offline_rental_configuration: Offline rental policy. :vartype offline_rental_configuration: ~azure.mgmt.media.models.ContentKeyPolicyFairPlayOfflineRentalConfiguration """ _validation = { - 'odata_type': {'required': True}, - 'ask': {'required': True}, - 'fair_play_pfx_password': {'required': True}, - 'fair_play_pfx': {'required': True}, - 'rental_and_lease_key_type': {'required': True}, - 'rental_duration': {'required': True}, + "odata_type": {"required": True}, + "ask": {"required": True}, + "fair_play_pfx_password": {"required": True}, + "fair_play_pfx": {"required": True}, + "rental_and_lease_key_type": {"required": True}, + "rental_duration": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'ask': {'key': 'ask', 'type': 'bytearray'}, - 'fair_play_pfx_password': {'key': 'fairPlayPfxPassword', 'type': 'str'}, - 'fair_play_pfx': {'key': 'fairPlayPfx', 'type': 'str'}, - 'rental_and_lease_key_type': {'key': 'rentalAndLeaseKeyType', 'type': 'str'}, - 'rental_duration': {'key': 'rentalDuration', 'type': 'long'}, - 'offline_rental_configuration': {'key': 'offlineRentalConfiguration', 'type': 'ContentKeyPolicyFairPlayOfflineRentalConfiguration'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "ask": {"key": "ask", "type": "bytearray"}, + "fair_play_pfx_password": {"key": "fairPlayPfxPassword", "type": "str"}, + "fair_play_pfx": {"key": "fairPlayPfx", "type": "str"}, + "rental_and_lease_key_type": {"key": "rentalAndLeaseKeyType", "type": "str"}, + "rental_duration": {"key": "rentalDuration", "type": "int"}, + "offline_rental_configuration": { + "key": "offlineRentalConfiguration", + "type": "ContentKeyPolicyFairPlayOfflineRentalConfiguration", + }, } def __init__( self, *, - ask: bytearray, + ask: bytes, fair_play_pfx_password: str, fair_play_pfx: str, rental_and_lease_key_type: Union[str, "_models.ContentKeyPolicyFairPlayRentalAndLeaseKeyType"], @@ -2176,26 +2278,26 @@ def __init__( **kwargs ): """ - :keyword ask: Required. The key that must be used as FairPlay Application Secret key. - :paramtype ask: bytearray - :keyword fair_play_pfx_password: Required. The password encrypting FairPlay certificate in PKCS - 12 (pfx) format. + :keyword ask: The key that must be used as FairPlay Application Secret key. Required. + :paramtype ask: bytes + :keyword fair_play_pfx_password: The password encrypting FairPlay certificate in PKCS 12 (pfx) + format. Required. :paramtype fair_play_pfx_password: str - :keyword fair_play_pfx: Required. The Base64 representation of FairPlay certificate in PKCS 12 - (pfx) format (including private key). + :keyword fair_play_pfx: The Base64 representation of FairPlay certificate in PKCS 12 (pfx) + format (including private key). Required. :paramtype fair_play_pfx: str - :keyword rental_and_lease_key_type: Required. The rental and lease key type. Known values are: - "Unknown", "Undefined", "DualExpiry", "PersistentUnlimited", "PersistentLimited". + :keyword rental_and_lease_key_type: The rental and lease key type. Required. Known values are: + "Unknown", "Undefined", "DualExpiry", "PersistentUnlimited", and "PersistentLimited". :paramtype rental_and_lease_key_type: str or ~azure.mgmt.media.models.ContentKeyPolicyFairPlayRentalAndLeaseKeyType - :keyword rental_duration: Required. The rental duration. Must be greater than or equal to 0. - :paramtype rental_duration: long + :keyword rental_duration: The rental duration. Must be greater than or equal to 0. Required. + :paramtype rental_duration: int :keyword offline_rental_configuration: Offline rental policy. :paramtype offline_rental_configuration: ~azure.mgmt.media.models.ContentKeyPolicyFairPlayOfflineRentalConfiguration """ - super(ContentKeyPolicyFairPlayConfiguration, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyFairPlayConfiguration' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyFairPlayConfiguration" # type: str self.ask = ask self.fair_play_pfx_password = fair_play_pfx_password self.fair_play_pfx = fair_play_pfx @@ -2204,76 +2306,71 @@ def __init__( self.offline_rental_configuration = offline_rental_configuration -class ContentKeyPolicyFairPlayOfflineRentalConfiguration(msrest.serialization.Model): +class ContentKeyPolicyFairPlayOfflineRentalConfiguration(_serialization.Model): """ContentKeyPolicyFairPlayOfflineRentalConfiguration. All required parameters must be populated in order to send to Azure. - :ivar playback_duration_seconds: Required. Playback duration. - :vartype playback_duration_seconds: long - :ivar storage_duration_seconds: Required. Storage duration. - :vartype storage_duration_seconds: long + :ivar playback_duration_seconds: Playback duration. Required. + :vartype playback_duration_seconds: int + :ivar storage_duration_seconds: Storage duration. Required. + :vartype storage_duration_seconds: int """ _validation = { - 'playback_duration_seconds': {'required': True}, - 'storage_duration_seconds': {'required': True}, + "playback_duration_seconds": {"required": True}, + "storage_duration_seconds": {"required": True}, } _attribute_map = { - 'playback_duration_seconds': {'key': 'playbackDurationSeconds', 'type': 'long'}, - 'storage_duration_seconds': {'key': 'storageDurationSeconds', 'type': 'long'}, + "playback_duration_seconds": {"key": "playbackDurationSeconds", "type": "int"}, + "storage_duration_seconds": {"key": "storageDurationSeconds", "type": "int"}, } - def __init__( - self, - *, - playback_duration_seconds: int, - storage_duration_seconds: int, - **kwargs - ): + def __init__(self, *, playback_duration_seconds: int, storage_duration_seconds: int, **kwargs): """ - :keyword playback_duration_seconds: Required. Playback duration. - :paramtype playback_duration_seconds: long - :keyword storage_duration_seconds: Required. Storage duration. - :paramtype storage_duration_seconds: long + :keyword playback_duration_seconds: Playback duration. Required. + :paramtype playback_duration_seconds: int + :keyword storage_duration_seconds: Storage duration. Required. + :paramtype storage_duration_seconds: int """ - super(ContentKeyPolicyFairPlayOfflineRentalConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.playback_duration_seconds = playback_duration_seconds self.storage_duration_seconds = storage_duration_seconds -class ContentKeyPolicyRestriction(msrest.serialization.Model): +class ContentKeyPolicyRestriction(_serialization.Model): """Base class for Content Key Policy restrictions. A derived class must be used to create a restriction. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentKeyPolicyOpenRestriction, ContentKeyPolicyTokenRestriction, ContentKeyPolicyUnknownRestriction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentKeyPolicyOpenRestriction, ContentKeyPolicyTokenRestriction, + ContentKeyPolicyUnknownRestriction All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.ContentKeyPolicyOpenRestriction': 'ContentKeyPolicyOpenRestriction', '#Microsoft.Media.ContentKeyPolicyTokenRestriction': 'ContentKeyPolicyTokenRestriction', '#Microsoft.Media.ContentKeyPolicyUnknownRestriction': 'ContentKeyPolicyUnknownRestriction'} + "odata_type": { + "#Microsoft.Media.ContentKeyPolicyOpenRestriction": "ContentKeyPolicyOpenRestriction", + "#Microsoft.Media.ContentKeyPolicyTokenRestriction": "ContentKeyPolicyTokenRestriction", + "#Microsoft.Media.ContentKeyPolicyUnknownRestriction": "ContentKeyPolicyUnknownRestriction", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyRestriction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -2282,29 +2379,25 @@ class ContentKeyPolicyOpenRestriction(ContentKeyPolicyRestriction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyOpenRestriction, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyOpenRestriction' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyOpenRestriction" # type: str -class ContentKeyPolicyOption(msrest.serialization.Model): +class ContentKeyPolicyOption(_serialization.Model): """Represents a policy option. Variables are only populated by the server, and will be ignored when sending a request. @@ -2315,24 +2408,24 @@ class ContentKeyPolicyOption(msrest.serialization.Model): :vartype policy_option_id: str :ivar name: The Policy Option description. :vartype name: str - :ivar configuration: Required. The key delivery configuration. + :ivar configuration: The key delivery configuration. Required. :vartype configuration: ~azure.mgmt.media.models.ContentKeyPolicyConfiguration - :ivar restriction: Required. The requirements that must be met to deliver keys with this - configuration. + :ivar restriction: The requirements that must be met to deliver keys with this configuration. + Required. :vartype restriction: ~azure.mgmt.media.models.ContentKeyPolicyRestriction """ _validation = { - 'policy_option_id': {'readonly': True}, - 'configuration': {'required': True}, - 'restriction': {'required': True}, + "policy_option_id": {"readonly": True}, + "configuration": {"required": True}, + "restriction": {"required": True}, } _attribute_map = { - 'policy_option_id': {'key': 'policyOptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'configuration': {'key': 'configuration', 'type': 'ContentKeyPolicyConfiguration'}, - 'restriction': {'key': 'restriction', 'type': 'ContentKeyPolicyRestriction'}, + "policy_option_id": {"key": "policyOptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "configuration": {"key": "configuration", "type": "ContentKeyPolicyConfiguration"}, + "restriction": {"key": "restriction", "type": "ContentKeyPolicyRestriction"}, } def __init__( @@ -2346,13 +2439,13 @@ def __init__( """ :keyword name: The Policy Option description. :paramtype name: str - :keyword configuration: Required. The key delivery configuration. + :keyword configuration: The key delivery configuration. Required. :paramtype configuration: ~azure.mgmt.media.models.ContentKeyPolicyConfiguration - :keyword restriction: Required. The requirements that must be met to deliver keys with this - configuration. + :keyword restriction: The requirements that must be met to deliver keys with this + configuration. Required. :paramtype restriction: ~azure.mgmt.media.models.ContentKeyPolicyRestriction """ - super(ContentKeyPolicyOption, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_option_id = None self.name = name self.configuration = configuration @@ -2364,23 +2457,23 @@ class ContentKeyPolicyPlayReadyConfiguration(ContentKeyPolicyConfiguration): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar licenses: Required. The PlayReady licenses. + :ivar licenses: The PlayReady licenses. Required. :vartype licenses: list[~azure.mgmt.media.models.ContentKeyPolicyPlayReadyLicense] :ivar response_custom_data: The custom response data. :vartype response_custom_data: str """ _validation = { - 'odata_type': {'required': True}, - 'licenses': {'required': True}, + "odata_type": {"required": True}, + "licenses": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'licenses': {'key': 'licenses', 'type': '[ContentKeyPolicyPlayReadyLicense]'}, - 'response_custom_data': {'key': 'responseCustomData', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "licenses": {"key": "licenses", "type": "[ContentKeyPolicyPlayReadyLicense]"}, + "response_custom_data": {"key": "responseCustomData", "type": "str"}, } def __init__( @@ -2391,48 +2484,48 @@ def __init__( **kwargs ): """ - :keyword licenses: Required. The PlayReady licenses. + :keyword licenses: The PlayReady licenses. Required. :paramtype licenses: list[~azure.mgmt.media.models.ContentKeyPolicyPlayReadyLicense] :keyword response_custom_data: The custom response data. :paramtype response_custom_data: str """ - super(ContentKeyPolicyPlayReadyConfiguration, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyPlayReadyConfiguration" # type: str self.licenses = licenses self.response_custom_data = response_custom_data -class ContentKeyPolicyPlayReadyContentKeyLocation(msrest.serialization.Model): +class ContentKeyPolicyPlayReadyContentKeyLocation(_serialization.Model): """Base class for content key ID location. A derived class must be used to represent the location. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader, ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader, + ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader': 'ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader', '#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier': 'ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier'} + "odata_type": { + "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader": "ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader", + "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier": "ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyPlayReadyContentKeyLocation, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -2441,26 +2534,22 @@ class ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader(ContentKeyPolicyPl All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader" # type: str class ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier(ContentKeyPolicyPlayReadyContentKeyLocation): @@ -2468,87 +2557,79 @@ class ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier(ContentKeyP All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar key_id: Required. The content key ID. + :ivar key_id: The content key ID. Required. :vartype key_id: str """ _validation = { - 'odata_type': {'required': True}, - 'key_id': {'required': True}, + "odata_type": {"required": True}, + "key_id": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'key_id': {'key': 'keyId', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "key_id": {"key": "keyId", "type": "str"}, } - def __init__( - self, - *, - key_id: str, - **kwargs - ): + def __init__(self, *, key_id: str, **kwargs): """ - :keyword key_id: Required. The content key ID. + :keyword key_id: The content key ID. Required. :paramtype key_id: str """ - super(ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyPlayReadyContentEncryptionKeyFromKeyIdentifier" # type: str self.key_id = key_id -class ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction(msrest.serialization.Model): +class ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction(_serialization.Model): """Configures the Explicit Analog Television Output Restriction control bits. For further details see the PlayReady Compliance Rules. All required parameters must be populated in order to send to Azure. - :ivar best_effort: Required. Indicates whether this restriction is enforced on a Best Effort - basis. + :ivar best_effort: Indicates whether this restriction is enforced on a Best Effort basis. + Required. :vartype best_effort: bool - :ivar configuration_data: Required. Configures the restriction control bits. Must be between 0 - and 3 inclusive. + :ivar configuration_data: Configures the restriction control bits. Must be between 0 and 3 + inclusive. Required. :vartype configuration_data: int """ _validation = { - 'best_effort': {'required': True}, - 'configuration_data': {'required': True}, + "best_effort": {"required": True}, + "configuration_data": {"required": True}, } _attribute_map = { - 'best_effort': {'key': 'bestEffort', 'type': 'bool'}, - 'configuration_data': {'key': 'configurationData', 'type': 'int'}, + "best_effort": {"key": "bestEffort", "type": "bool"}, + "configuration_data": {"key": "configurationData", "type": "int"}, } - def __init__( - self, - *, - best_effort: bool, - configuration_data: int, - **kwargs - ): + def __init__(self, *, best_effort: bool, configuration_data: int, **kwargs): """ - :keyword best_effort: Required. Indicates whether this restriction is enforced on a Best Effort - basis. + :keyword best_effort: Indicates whether this restriction is enforced on a Best Effort basis. + Required. :paramtype best_effort: bool - :keyword configuration_data: Required. Configures the restriction control bits. Must be between - 0 and 3 inclusive. + :keyword configuration_data: Configures the restriction control bits. Must be between 0 and 3 + inclusive. Required. :paramtype configuration_data: int """ - super(ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.best_effort = best_effort self.configuration_data = configuration_data -class ContentKeyPolicyPlayReadyLicense(msrest.serialization.Model): +class ContentKeyPolicyPlayReadyLicense(_serialization.Model): # pylint: disable=too-many-instance-attributes """The PlayReady license. All required parameters must be populated in order to send to Azure. - :ivar allow_test_devices: Required. A flag indicating whether test devices can use the license. + :ivar allow_test_devices: A flag indicating whether test devices can use the license. Required. :vartype allow_test_devices: bool + :ivar security_level: The security level. Known values are: "Unknown", "SL150", "SL2000", and + "SL3000". + :vartype security_level: str or ~azure.mgmt.media.models.SecurityLevel :ivar begin_date: The begin date of license. :vartype begin_date: ~datetime.datetime :ivar expiration_date: The expiration date of license. @@ -2561,35 +2642,36 @@ class ContentKeyPolicyPlayReadyLicense(msrest.serialization.Model): :vartype grace_period: ~datetime.timedelta :ivar play_right: The license PlayRight. :vartype play_right: ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyPlayRight - :ivar license_type: Required. The license type. Known values are: "Unknown", "NonPersistent", - "Persistent". + :ivar license_type: The license type. Required. Known values are: "Unknown", "NonPersistent", + and "Persistent". :vartype license_type: str or ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyLicenseType - :ivar content_key_location: Required. The content key location. + :ivar content_key_location: The content key location. Required. :vartype content_key_location: ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyContentKeyLocation - :ivar content_type: Required. The PlayReady content type. Known values are: "Unknown", - "Unspecified", "UltraVioletDownload", "UltraVioletStreaming". + :ivar content_type: The PlayReady content type. Required. Known values are: "Unknown", + "Unspecified", "UltraVioletDownload", and "UltraVioletStreaming". :vartype content_type: str or ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyContentType """ _validation = { - 'allow_test_devices': {'required': True}, - 'license_type': {'required': True}, - 'content_key_location': {'required': True}, - 'content_type': {'required': True}, + "allow_test_devices": {"required": True}, + "license_type": {"required": True}, + "content_key_location": {"required": True}, + "content_type": {"required": True}, } _attribute_map = { - 'allow_test_devices': {'key': 'allowTestDevices', 'type': 'bool'}, - 'begin_date': {'key': 'beginDate', 'type': 'iso-8601'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'iso-8601'}, - 'relative_begin_date': {'key': 'relativeBeginDate', 'type': 'duration'}, - 'relative_expiration_date': {'key': 'relativeExpirationDate', 'type': 'duration'}, - 'grace_period': {'key': 'gracePeriod', 'type': 'duration'}, - 'play_right': {'key': 'playRight', 'type': 'ContentKeyPolicyPlayReadyPlayRight'}, - 'license_type': {'key': 'licenseType', 'type': 'str'}, - 'content_key_location': {'key': 'contentKeyLocation', 'type': 'ContentKeyPolicyPlayReadyContentKeyLocation'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, + "allow_test_devices": {"key": "allowTestDevices", "type": "bool"}, + "security_level": {"key": "securityLevel", "type": "str"}, + "begin_date": {"key": "beginDate", "type": "iso-8601"}, + "expiration_date": {"key": "expirationDate", "type": "iso-8601"}, + "relative_begin_date": {"key": "relativeBeginDate", "type": "duration"}, + "relative_expiration_date": {"key": "relativeExpirationDate", "type": "duration"}, + "grace_period": {"key": "gracePeriod", "type": "duration"}, + "play_right": {"key": "playRight", "type": "ContentKeyPolicyPlayReadyPlayRight"}, + "license_type": {"key": "licenseType", "type": "str"}, + "content_key_location": {"key": "contentKeyLocation", "type": "ContentKeyPolicyPlayReadyContentKeyLocation"}, + "content_type": {"key": "contentType", "type": "str"}, } def __init__( @@ -2599,6 +2681,7 @@ def __init__( license_type: Union[str, "_models.ContentKeyPolicyPlayReadyLicenseType"], content_key_location: "_models.ContentKeyPolicyPlayReadyContentKeyLocation", content_type: Union[str, "_models.ContentKeyPolicyPlayReadyContentType"], + security_level: Optional[Union[str, "_models.SecurityLevel"]] = None, begin_date: Optional[datetime.datetime] = None, expiration_date: Optional[datetime.datetime] = None, relative_begin_date: Optional[datetime.timedelta] = None, @@ -2608,9 +2691,12 @@ def __init__( **kwargs ): """ - :keyword allow_test_devices: Required. A flag indicating whether test devices can use the - license. + :keyword allow_test_devices: A flag indicating whether test devices can use the license. + Required. :paramtype allow_test_devices: bool + :keyword security_level: The security level. Known values are: "Unknown", "SL150", "SL2000", + and "SL3000". + :paramtype security_level: str or ~azure.mgmt.media.models.SecurityLevel :keyword begin_date: The begin date of license. :paramtype begin_date: ~datetime.datetime :keyword expiration_date: The expiration date of license. @@ -2623,18 +2709,19 @@ def __init__( :paramtype grace_period: ~datetime.timedelta :keyword play_right: The license PlayRight. :paramtype play_right: ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyPlayRight - :keyword license_type: Required. The license type. Known values are: "Unknown", - "NonPersistent", "Persistent". + :keyword license_type: The license type. Required. Known values are: "Unknown", + "NonPersistent", and "Persistent". :paramtype license_type: str or ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyLicenseType - :keyword content_key_location: Required. The content key location. + :keyword content_key_location: The content key location. Required. :paramtype content_key_location: ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyContentKeyLocation - :keyword content_type: Required. The PlayReady content type. Known values are: "Unknown", - "Unspecified", "UltraVioletDownload", "UltraVioletStreaming". + :keyword content_type: The PlayReady content type. Required. Known values are: "Unknown", + "Unspecified", "UltraVioletDownload", and "UltraVioletStreaming". :paramtype content_type: str or ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyContentType """ - super(ContentKeyPolicyPlayReadyLicense, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_test_devices = allow_test_devices + self.security_level = security_level self.begin_date = begin_date self.expiration_date = expiration_date self.relative_begin_date = relative_begin_date @@ -2646,7 +2733,7 @@ def __init__( self.content_type = content_type -class ContentKeyPolicyPlayReadyPlayRight(msrest.serialization.Model): +class ContentKeyPolicyPlayReadyPlayRight(_serialization.Model): # pylint: disable=too-many-instance-attributes """Configures the Play Right in the PlayReady license. All required parameters must be populated in order to send to Azure. @@ -2664,17 +2751,17 @@ class ContentKeyPolicyPlayReadyPlayRight(msrest.serialization.Model): Output Restriction in the license. Configuration data must be between 0 and 3 inclusive. :vartype explicit_analog_television_output_restriction: ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction - :ivar digital_video_only_content_restriction: Required. Enables the Image Constraint For Analog - Component Video Restriction in the license. + :ivar digital_video_only_content_restriction: Enables the Image Constraint For Analog Component + Video Restriction in the license. Required. :vartype digital_video_only_content_restriction: bool - :ivar image_constraint_for_analog_component_video_restriction: Required. Enables the Image - Constraint For Analog Component Video Restriction in the license. + :ivar image_constraint_for_analog_component_video_restriction: Enables the Image Constraint For + Analog Component Video Restriction in the license. Required. :vartype image_constraint_for_analog_component_video_restriction: bool - :ivar image_constraint_for_analog_computer_monitor_restriction: Required. Enables the Image - Constraint For Analog Component Video Restriction in the license. + :ivar image_constraint_for_analog_computer_monitor_restriction: Enables the Image Constraint + For Analog Component Video Restriction in the license. Required. :vartype image_constraint_for_analog_computer_monitor_restriction: bool - :ivar allow_passing_video_content_to_unknown_output: Required. Configures Unknown output - handling settings of the license. Known values are: "Unknown", "NotAllowed", "Allowed", + :ivar allow_passing_video_content_to_unknown_output: Configures Unknown output handling + settings of the license. Required. Known values are: "Unknown", "NotAllowed", "Allowed", and "AllowedWithVideoConstriction". :vartype allow_passing_video_content_to_unknown_output: str or ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyUnknownOutputPassingOption @@ -2695,26 +2782,38 @@ class ContentKeyPolicyPlayReadyPlayRight(msrest.serialization.Model): """ _validation = { - 'digital_video_only_content_restriction': {'required': True}, - 'image_constraint_for_analog_component_video_restriction': {'required': True}, - 'image_constraint_for_analog_computer_monitor_restriction': {'required': True}, - 'allow_passing_video_content_to_unknown_output': {'required': True}, + "digital_video_only_content_restriction": {"required": True}, + "image_constraint_for_analog_component_video_restriction": {"required": True}, + "image_constraint_for_analog_computer_monitor_restriction": {"required": True}, + "allow_passing_video_content_to_unknown_output": {"required": True}, } _attribute_map = { - 'first_play_expiration': {'key': 'firstPlayExpiration', 'type': 'duration'}, - 'scms_restriction': {'key': 'scmsRestriction', 'type': 'int'}, - 'agc_and_color_stripe_restriction': {'key': 'agcAndColorStripeRestriction', 'type': 'int'}, - 'explicit_analog_television_output_restriction': {'key': 'explicitAnalogTelevisionOutputRestriction', 'type': 'ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction'}, - 'digital_video_only_content_restriction': {'key': 'digitalVideoOnlyContentRestriction', 'type': 'bool'}, - 'image_constraint_for_analog_component_video_restriction': {'key': 'imageConstraintForAnalogComponentVideoRestriction', 'type': 'bool'}, - 'image_constraint_for_analog_computer_monitor_restriction': {'key': 'imageConstraintForAnalogComputerMonitorRestriction', 'type': 'bool'}, - 'allow_passing_video_content_to_unknown_output': {'key': 'allowPassingVideoContentToUnknownOutput', 'type': 'str'}, - 'uncompressed_digital_video_opl': {'key': 'uncompressedDigitalVideoOpl', 'type': 'int'}, - 'compressed_digital_video_opl': {'key': 'compressedDigitalVideoOpl', 'type': 'int'}, - 'analog_video_opl': {'key': 'analogVideoOpl', 'type': 'int'}, - 'compressed_digital_audio_opl': {'key': 'compressedDigitalAudioOpl', 'type': 'int'}, - 'uncompressed_digital_audio_opl': {'key': 'uncompressedDigitalAudioOpl', 'type': 'int'}, + "first_play_expiration": {"key": "firstPlayExpiration", "type": "duration"}, + "scms_restriction": {"key": "scmsRestriction", "type": "int"}, + "agc_and_color_stripe_restriction": {"key": "agcAndColorStripeRestriction", "type": "int"}, + "explicit_analog_television_output_restriction": { + "key": "explicitAnalogTelevisionOutputRestriction", + "type": "ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction", + }, + "digital_video_only_content_restriction": {"key": "digitalVideoOnlyContentRestriction", "type": "bool"}, + "image_constraint_for_analog_component_video_restriction": { + "key": "imageConstraintForAnalogComponentVideoRestriction", + "type": "bool", + }, + "image_constraint_for_analog_computer_monitor_restriction": { + "key": "imageConstraintForAnalogComputerMonitorRestriction", + "type": "bool", + }, + "allow_passing_video_content_to_unknown_output": { + "key": "allowPassingVideoContentToUnknownOutput", + "type": "str", + }, + "uncompressed_digital_video_opl": {"key": "uncompressedDigitalVideoOpl", "type": "int"}, + "compressed_digital_video_opl": {"key": "compressedDigitalVideoOpl", "type": "int"}, + "analog_video_opl": {"key": "analogVideoOpl", "type": "int"}, + "compressed_digital_audio_opl": {"key": "compressedDigitalAudioOpl", "type": "int"}, + "uncompressed_digital_audio_opl": {"key": "uncompressedDigitalAudioOpl", "type": "int"}, } def __init__( @@ -2723,11 +2822,15 @@ def __init__( digital_video_only_content_restriction: bool, image_constraint_for_analog_component_video_restriction: bool, image_constraint_for_analog_computer_monitor_restriction: bool, - allow_passing_video_content_to_unknown_output: Union[str, "_models.ContentKeyPolicyPlayReadyUnknownOutputPassingOption"], + allow_passing_video_content_to_unknown_output: Union[ + str, "_models.ContentKeyPolicyPlayReadyUnknownOutputPassingOption" + ], first_play_expiration: Optional[datetime.timedelta] = None, scms_restriction: Optional[int] = None, agc_and_color_stripe_restriction: Optional[int] = None, - explicit_analog_television_output_restriction: Optional["_models.ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction"] = None, + explicit_analog_television_output_restriction: Optional[ + "_models.ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction" + ] = None, uncompressed_digital_video_opl: Optional[int] = None, compressed_digital_video_opl: Optional[int] = None, analog_video_opl: Optional[int] = None, @@ -2750,17 +2853,17 @@ def __init__( inclusive. :paramtype explicit_analog_television_output_restriction: ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyExplicitAnalogTelevisionRestriction - :keyword digital_video_only_content_restriction: Required. Enables the Image Constraint For - Analog Component Video Restriction in the license. + :keyword digital_video_only_content_restriction: Enables the Image Constraint For Analog + Component Video Restriction in the license. Required. :paramtype digital_video_only_content_restriction: bool - :keyword image_constraint_for_analog_component_video_restriction: Required. Enables the Image - Constraint For Analog Component Video Restriction in the license. + :keyword image_constraint_for_analog_component_video_restriction: Enables the Image Constraint + For Analog Component Video Restriction in the license. Required. :paramtype image_constraint_for_analog_component_video_restriction: bool - :keyword image_constraint_for_analog_computer_monitor_restriction: Required. Enables the Image - Constraint For Analog Component Video Restriction in the license. + :keyword image_constraint_for_analog_computer_monitor_restriction: Enables the Image Constraint + For Analog Component Video Restriction in the license. Required. :paramtype image_constraint_for_analog_computer_monitor_restriction: bool - :keyword allow_passing_video_content_to_unknown_output: Required. Configures Unknown output - handling settings of the license. Known values are: "Unknown", "NotAllowed", "Allowed", + :keyword allow_passing_video_content_to_unknown_output: Configures Unknown output handling + settings of the license. Required. Known values are: "Unknown", "NotAllowed", "Allowed", and "AllowedWithVideoConstriction". :paramtype allow_passing_video_content_to_unknown_output: str or ~azure.mgmt.media.models.ContentKeyPolicyPlayReadyUnknownOutputPassingOption @@ -2779,14 +2882,18 @@ def __init__( digital audio. :paramtype uncompressed_digital_audio_opl: int """ - super(ContentKeyPolicyPlayReadyPlayRight, self).__init__(**kwargs) + super().__init__(**kwargs) self.first_play_expiration = first_play_expiration self.scms_restriction = scms_restriction self.agc_and_color_stripe_restriction = agc_and_color_stripe_restriction self.explicit_analog_television_output_restriction = explicit_analog_television_output_restriction self.digital_video_only_content_restriction = digital_video_only_content_restriction - self.image_constraint_for_analog_component_video_restriction = image_constraint_for_analog_component_video_restriction - self.image_constraint_for_analog_computer_monitor_restriction = image_constraint_for_analog_computer_monitor_restriction + self.image_constraint_for_analog_component_video_restriction = ( + image_constraint_for_analog_component_video_restriction + ) + self.image_constraint_for_analog_computer_monitor_restriction = ( + image_constraint_for_analog_computer_monitor_restriction + ) self.allow_passing_video_content_to_unknown_output = allow_passing_video_content_to_unknown_output self.uncompressed_digital_video_opl = uncompressed_digital_video_opl self.compressed_digital_video_opl = compressed_digital_video_opl @@ -2795,7 +2902,7 @@ def __init__( self.uncompressed_digital_audio_opl = uncompressed_digital_audio_opl -class ContentKeyPolicyProperties(msrest.serialization.Model): +class ContentKeyPolicyProperties(_serialization.Model): """The properties of the Content Key Policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -2810,39 +2917,33 @@ class ContentKeyPolicyProperties(msrest.serialization.Model): :vartype last_modified: ~datetime.datetime :ivar description: A description for the Policy. :vartype description: str - :ivar options: Required. The Key Policy options. + :ivar options: The Key Policy options. Required. :vartype options: list[~azure.mgmt.media.models.ContentKeyPolicyOption] """ _validation = { - 'policy_id': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, - 'options': {'required': True}, + "policy_id": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"readonly": True}, + "options": {"required": True}, } _attribute_map = { - 'policy_id': {'key': 'policyId', 'type': 'str'}, - 'created': {'key': 'created', 'type': 'iso-8601'}, - 'last_modified': {'key': 'lastModified', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - 'options': {'key': 'options', 'type': '[ContentKeyPolicyOption]'}, + "policy_id": {"key": "policyId", "type": "str"}, + "created": {"key": "created", "type": "iso-8601"}, + "last_modified": {"key": "lastModified", "type": "iso-8601"}, + "description": {"key": "description", "type": "str"}, + "options": {"key": "options", "type": "[ContentKeyPolicyOption]"}, } - def __init__( - self, - *, - options: List["_models.ContentKeyPolicyOption"], - description: Optional[str] = None, - **kwargs - ): + def __init__(self, *, options: List["_models.ContentKeyPolicyOption"], description: Optional[str] = None, **kwargs): """ :keyword description: A description for the Policy. :paramtype description: str - :keyword options: Required. The Key Policy options. + :keyword options: The Key Policy options. Required. :paramtype options: list[~azure.mgmt.media.models.ContentKeyPolicyOption] """ - super(ContentKeyPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.created = None self.last_modified = None @@ -2850,37 +2951,38 @@ def __init__( self.options = options -class ContentKeyPolicyRestrictionTokenKey(msrest.serialization.Model): +class ContentKeyPolicyRestrictionTokenKey(_serialization.Model): """Base class for Content Key Policy key for token validation. A derived class must be used to create a token key. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContentKeyPolicyRsaTokenKey, ContentKeyPolicySymmetricTokenKey, ContentKeyPolicyX509CertificateTokenKey. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContentKeyPolicyRsaTokenKey, ContentKeyPolicySymmetricTokenKey, + ContentKeyPolicyX509CertificateTokenKey All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.ContentKeyPolicyRsaTokenKey': 'ContentKeyPolicyRsaTokenKey', '#Microsoft.Media.ContentKeyPolicySymmetricTokenKey': 'ContentKeyPolicySymmetricTokenKey', '#Microsoft.Media.ContentKeyPolicyX509CertificateTokenKey': 'ContentKeyPolicyX509CertificateTokenKey'} + "odata_type": { + "#Microsoft.Media.ContentKeyPolicyRsaTokenKey": "ContentKeyPolicyRsaTokenKey", + "#Microsoft.Media.ContentKeyPolicySymmetricTokenKey": "ContentKeyPolicySymmetricTokenKey", + "#Microsoft.Media.ContentKeyPolicyX509CertificateTokenKey": "ContentKeyPolicyX509CertificateTokenKey", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyRestrictionTokenKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -2889,41 +2991,35 @@ class ContentKeyPolicyRsaTokenKey(ContentKeyPolicyRestrictionTokenKey): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar exponent: Required. The RSA Parameter exponent. - :vartype exponent: bytearray - :ivar modulus: Required. The RSA Parameter modulus. - :vartype modulus: bytearray + :ivar exponent: The RSA Parameter exponent. Required. + :vartype exponent: bytes + :ivar modulus: The RSA Parameter modulus. Required. + :vartype modulus: bytes """ _validation = { - 'odata_type': {'required': True}, - 'exponent': {'required': True}, - 'modulus': {'required': True}, + "odata_type": {"required": True}, + "exponent": {"required": True}, + "modulus": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'exponent': {'key': 'exponent', 'type': 'bytearray'}, - 'modulus': {'key': 'modulus', 'type': 'bytearray'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "exponent": {"key": "exponent", "type": "bytearray"}, + "modulus": {"key": "modulus", "type": "bytearray"}, } - def __init__( - self, - *, - exponent: bytearray, - modulus: bytearray, - **kwargs - ): + def __init__(self, *, exponent: bytes, modulus: bytes, **kwargs): """ - :keyword exponent: Required. The RSA Parameter exponent. - :paramtype exponent: bytearray - :keyword modulus: Required. The RSA Parameter modulus. - :paramtype modulus: bytearray + :keyword exponent: The RSA Parameter exponent. Required. + :paramtype exponent: bytes + :keyword modulus: The RSA Parameter modulus. Required. + :paramtype modulus: bytes """ - super(ContentKeyPolicyRsaTokenKey, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyRsaTokenKey' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyRsaTokenKey" # type: str self.exponent = exponent self.modulus = modulus @@ -2933,38 +3029,33 @@ class ContentKeyPolicySymmetricTokenKey(ContentKeyPolicyRestrictionTokenKey): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar key_value: Required. The key value of the key. - :vartype key_value: bytearray + :ivar key_value: The key value of the key. Required. + :vartype key_value: bytes """ _validation = { - 'odata_type': {'required': True}, - 'key_value': {'required': True}, + "odata_type": {"required": True}, + "key_value": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'key_value': {'key': 'keyValue', 'type': 'bytearray'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "key_value": {"key": "keyValue", "type": "bytearray"}, } - def __init__( - self, - *, - key_value: bytearray, - **kwargs - ): + def __init__(self, *, key_value: bytes, **kwargs): """ - :keyword key_value: Required. The key value of the key. - :paramtype key_value: bytearray + :keyword key_value: The key value of the key. Required. + :paramtype key_value: bytes """ - super(ContentKeyPolicySymmetricTokenKey, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicySymmetricTokenKey' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicySymmetricTokenKey" # type: str self.key_value = key_value -class ContentKeyPolicyTokenClaim(msrest.serialization.Model): +class ContentKeyPolicyTokenClaim(_serialization.Model): """Represents a token claim. :ivar claim_type: Token claim type. @@ -2974,24 +3065,18 @@ class ContentKeyPolicyTokenClaim(msrest.serialization.Model): """ _attribute_map = { - 'claim_type': {'key': 'claimType', 'type': 'str'}, - 'claim_value': {'key': 'claimValue', 'type': 'str'}, + "claim_type": {"key": "claimType", "type": "str"}, + "claim_value": {"key": "claimValue", "type": "str"}, } - def __init__( - self, - *, - claim_type: Optional[str] = None, - claim_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, claim_type: Optional[str] = None, claim_value: Optional[str] = None, **kwargs): """ :keyword claim_type: Token claim type. :paramtype claim_type: str :keyword claim_value: Token claim value. :paramtype claim_value: str """ - super(ContentKeyPolicyTokenClaim, self).__init__(**kwargs) + super().__init__(**kwargs) self.claim_type = claim_type self.claim_value = claim_value @@ -3001,21 +3086,21 @@ class ContentKeyPolicyTokenRestriction(ContentKeyPolicyRestriction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar issuer: Required. The token issuer. + :ivar issuer: The token issuer. Required. :vartype issuer: str - :ivar audience: Required. The audience for the token. + :ivar audience: The audience for the token. Required. :vartype audience: str - :ivar primary_verification_key: Required. The primary verification key. + :ivar primary_verification_key: The primary verification key. Required. :vartype primary_verification_key: ~azure.mgmt.media.models.ContentKeyPolicyRestrictionTokenKey :ivar alternate_verification_keys: A list of alternative verification keys. :vartype alternate_verification_keys: list[~azure.mgmt.media.models.ContentKeyPolicyRestrictionTokenKey] :ivar required_claims: A list of required token claims. :vartype required_claims: list[~azure.mgmt.media.models.ContentKeyPolicyTokenClaim] - :ivar restriction_token_type: Required. The type of token. Known values are: "Unknown", "Swt", - "Jwt". + :ivar restriction_token_type: The type of token. Required. Known values are: "Unknown", "Swt", + and "Jwt". :vartype restriction_token_type: str or ~azure.mgmt.media.models.ContentKeyPolicyRestrictionTokenType :ivar open_id_connect_discovery_document: The OpenID connect discovery document. @@ -3023,22 +3108,25 @@ class ContentKeyPolicyTokenRestriction(ContentKeyPolicyRestriction): """ _validation = { - 'odata_type': {'required': True}, - 'issuer': {'required': True}, - 'audience': {'required': True}, - 'primary_verification_key': {'required': True}, - 'restriction_token_type': {'required': True}, + "odata_type": {"required": True}, + "issuer": {"required": True}, + "audience": {"required": True}, + "primary_verification_key": {"required": True}, + "restriction_token_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'audience': {'key': 'audience', 'type': 'str'}, - 'primary_verification_key': {'key': 'primaryVerificationKey', 'type': 'ContentKeyPolicyRestrictionTokenKey'}, - 'alternate_verification_keys': {'key': 'alternateVerificationKeys', 'type': '[ContentKeyPolicyRestrictionTokenKey]'}, - 'required_claims': {'key': 'requiredClaims', 'type': '[ContentKeyPolicyTokenClaim]'}, - 'restriction_token_type': {'key': 'restrictionTokenType', 'type': 'str'}, - 'open_id_connect_discovery_document': {'key': 'openIdConnectDiscoveryDocument', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "audience": {"key": "audience", "type": "str"}, + "primary_verification_key": {"key": "primaryVerificationKey", "type": "ContentKeyPolicyRestrictionTokenKey"}, + "alternate_verification_keys": { + "key": "alternateVerificationKeys", + "type": "[ContentKeyPolicyRestrictionTokenKey]", + }, + "required_claims": {"key": "requiredClaims", "type": "[ContentKeyPolicyTokenClaim]"}, + "restriction_token_type": {"key": "restrictionTokenType", "type": "str"}, + "open_id_connect_discovery_document": {"key": "openIdConnectDiscoveryDocument", "type": "str"}, } def __init__( @@ -3054,11 +3142,11 @@ def __init__( **kwargs ): """ - :keyword issuer: Required. The token issuer. + :keyword issuer: The token issuer. Required. :paramtype issuer: str - :keyword audience: Required. The audience for the token. + :keyword audience: The audience for the token. Required. :paramtype audience: str - :keyword primary_verification_key: Required. The primary verification key. + :keyword primary_verification_key: The primary verification key. Required. :paramtype primary_verification_key: ~azure.mgmt.media.models.ContentKeyPolicyRestrictionTokenKey :keyword alternate_verification_keys: A list of alternative verification keys. @@ -3066,15 +3154,15 @@ def __init__( list[~azure.mgmt.media.models.ContentKeyPolicyRestrictionTokenKey] :keyword required_claims: A list of required token claims. :paramtype required_claims: list[~azure.mgmt.media.models.ContentKeyPolicyTokenClaim] - :keyword restriction_token_type: Required. The type of token. Known values are: "Unknown", - "Swt", "Jwt". + :keyword restriction_token_type: The type of token. Required. Known values are: "Unknown", + "Swt", and "Jwt". :paramtype restriction_token_type: str or ~azure.mgmt.media.models.ContentKeyPolicyRestrictionTokenType :keyword open_id_connect_discovery_document: The OpenID connect discovery document. :paramtype open_id_connect_discovery_document: str """ - super(ContentKeyPolicyTokenRestriction, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyTokenRestriction' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyTokenRestriction" # type: str self.issuer = issuer self.audience = audience self.primary_verification_key = primary_verification_key @@ -3089,26 +3177,22 @@ class ContentKeyPolicyUnknownConfiguration(ContentKeyPolicyConfiguration): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyUnknownConfiguration, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyUnknownConfiguration' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyUnknownConfiguration" # type: str class ContentKeyPolicyUnknownRestriction(ContentKeyPolicyRestriction): @@ -3116,26 +3200,22 @@ class ContentKeyPolicyUnknownRestriction(ContentKeyPolicyRestriction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentKeyPolicyUnknownRestriction, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyUnknownRestriction' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyUnknownRestriction" # type: str class ContentKeyPolicyWidevineConfiguration(ContentKeyPolicyConfiguration): @@ -3143,34 +3223,29 @@ class ContentKeyPolicyWidevineConfiguration(ContentKeyPolicyConfiguration): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar widevine_template: Required. The Widevine template. + :ivar widevine_template: The Widevine template. Required. :vartype widevine_template: str """ _validation = { - 'odata_type': {'required': True}, - 'widevine_template': {'required': True}, + "odata_type": {"required": True}, + "widevine_template": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'widevine_template': {'key': 'widevineTemplate', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "widevine_template": {"key": "widevineTemplate", "type": "str"}, } - def __init__( - self, - *, - widevine_template: str, - **kwargs - ): + def __init__(self, *, widevine_template: str, **kwargs): """ - :keyword widevine_template: Required. The Widevine template. + :keyword widevine_template: The Widevine template. Required. :paramtype widevine_template: str """ - super(ContentKeyPolicyWidevineConfiguration, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyWidevineConfiguration' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyWidevineConfiguration" # type: str self.widevine_template = widevine_template @@ -3179,36 +3254,31 @@ class ContentKeyPolicyX509CertificateTokenKey(ContentKeyPolicyRestrictionTokenKe All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar raw_body: Required. The raw data field of a certificate in PKCS 12 format - (X509Certificate2 in .NET). - :vartype raw_body: bytearray + :ivar raw_body: The raw data field of a certificate in PKCS 12 format (X509Certificate2 in + .NET). Required. + :vartype raw_body: bytes """ _validation = { - 'odata_type': {'required': True}, - 'raw_body': {'required': True}, + "odata_type": {"required": True}, + "raw_body": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'raw_body': {'key': 'rawBody', 'type': 'bytearray'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "raw_body": {"key": "rawBody", "type": "bytearray"}, } - def __init__( - self, - *, - raw_body: bytearray, - **kwargs - ): + def __init__(self, *, raw_body: bytes, **kwargs): """ - :keyword raw_body: Required. The raw data field of a certificate in PKCS 12 format - (X509Certificate2 in .NET). - :paramtype raw_body: bytearray + :keyword raw_body: The raw data field of a certificate in PKCS 12 format (X509Certificate2 in + .NET). Required. + :paramtype raw_body: bytes """ - super(ContentKeyPolicyX509CertificateTokenKey, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.ContentKeyPolicyX509CertificateTokenKey' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.ContentKeyPolicyX509CertificateTokenKey" # type: str self.raw_body = raw_body @@ -3217,34 +3287,29 @@ class CopyAudio(Codec): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, } - def __init__( - self, - *, - label: Optional[str] = None, - **kwargs - ): + def __init__(self, *, label: Optional[str] = None, **kwargs): """ :keyword label: An optional label for the codec. The label can be used to control muxing behavior. :paramtype label: str """ - super(CopyAudio, self).__init__(label=label, **kwargs) - self.odata_type = '#Microsoft.Media.CopyAudio' # type: str + super().__init__(label=label, **kwargs) + self.odata_type = "#Microsoft.Media.CopyAudio" # type: str class CopyVideo(Codec): @@ -3252,37 +3317,32 @@ class CopyVideo(Codec): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, } - def __init__( - self, - *, - label: Optional[str] = None, - **kwargs - ): + def __init__(self, *, label: Optional[str] = None, **kwargs): """ :keyword label: An optional label for the codec. The label can be used to control muxing behavior. :paramtype label: str """ - super(CopyVideo, self).__init__(label=label, **kwargs) - self.odata_type = '#Microsoft.Media.CopyVideo' # type: str + super().__init__(label=label, **kwargs) + self.odata_type = "#Microsoft.Media.CopyVideo" # type: str -class CrossSiteAccessPolicies(msrest.serialization.Model): +class CrossSiteAccessPolicies(_serialization.Model): """The client access policy. :ivar client_access_policy: The content of clientaccesspolicy.xml used by Silverlight. @@ -3292,16 +3352,12 @@ class CrossSiteAccessPolicies(msrest.serialization.Model): """ _attribute_map = { - 'client_access_policy': {'key': 'clientAccessPolicy', 'type': 'str'}, - 'cross_domain_policy': {'key': 'crossDomainPolicy', 'type': 'str'}, + "client_access_policy": {"key": "clientAccessPolicy", "type": "str"}, + "cross_domain_policy": {"key": "crossDomainPolicy", "type": "str"}, } def __init__( - self, - *, - client_access_policy: Optional[str] = None, - cross_domain_policy: Optional[str] = None, - **kwargs + self, *, client_access_policy: Optional[str] = None, cross_domain_policy: Optional[str] = None, **kwargs ): """ :keyword client_access_policy: The content of clientaccesspolicy.xml used by Silverlight. @@ -3309,12 +3365,32 @@ def __init__( :keyword cross_domain_policy: The content of crossdomain.xml used by Silverlight. :paramtype cross_domain_policy: str """ - super(CrossSiteAccessPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_access_policy = client_access_policy self.cross_domain_policy = cross_domain_policy -class DefaultKey(msrest.serialization.Model): +class DashSettings(_serialization.Model): + """The DASH setting for a track. + + :ivar role: The role for the DASH setting. + :vartype role: str + """ + + _attribute_map = { + "role": {"key": "role", "type": "str"}, + } + + def __init__(self, *, role: Optional[str] = None, **kwargs): + """ + :keyword role: The role for the DASH setting. + :paramtype role: str + """ + super().__init__(**kwargs) + self.role = role + + +class DefaultKey(_serialization.Model): """Class to specify properties of default content key for each encryption scheme. :ivar label: Label can be used to specify Content Key when creating a Streaming Locator. @@ -3324,42 +3400,36 @@ class DefaultKey(msrest.serialization.Model): """ _attribute_map = { - 'label': {'key': 'label', 'type': 'str'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, + "label": {"key": "label", "type": "str"}, + "policy_name": {"key": "policyName", "type": "str"}, } - def __init__( - self, - *, - label: Optional[str] = None, - policy_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, label: Optional[str] = None, policy_name: Optional[str] = None, **kwargs): """ :keyword label: Label can be used to specify Content Key when creating a Streaming Locator. :paramtype label: str :keyword policy_name: Policy used by Default Key. :paramtype policy_name: str """ - super(DefaultKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.label = label self.policy_name = policy_name -class Deinterlace(msrest.serialization.Model): +class Deinterlace(_serialization.Model): """Describes the de-interlacing settings. :ivar parity: The field parity for de-interlacing, defaults to Auto. Known values are: "Auto", - "TopFieldFirst", "BottomFieldFirst". + "TopFieldFirst", and "BottomFieldFirst". :vartype parity: str or ~azure.mgmt.media.models.DeinterlaceParity - :ivar mode: The deinterlacing mode. Defaults to AutoPixelAdaptive. Known values are: "Off", + :ivar mode: The deinterlacing mode. Defaults to AutoPixelAdaptive. Known values are: "Off" and "AutoPixelAdaptive". :vartype mode: str or ~azure.mgmt.media.models.DeinterlaceMode """ _attribute_map = { - 'parity': {'key': 'parity', 'type': 'str'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "parity": {"key": "parity", "type": "str"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( @@ -3371,18 +3441,18 @@ def __init__( ): """ :keyword parity: The field parity for de-interlacing, defaults to Auto. Known values are: - "Auto", "TopFieldFirst", "BottomFieldFirst". + "Auto", "TopFieldFirst", and "BottomFieldFirst". :paramtype parity: str or ~azure.mgmt.media.models.DeinterlaceParity - :keyword mode: The deinterlacing mode. Defaults to AutoPixelAdaptive. Known values are: "Off", - "AutoPixelAdaptive". + :keyword mode: The deinterlacing mode. Defaults to AutoPixelAdaptive. Known values are: "Off" + and "AutoPixelAdaptive". :paramtype mode: str or ~azure.mgmt.media.models.DeinterlaceMode """ - super(Deinterlace, self).__init__(**kwargs) + super().__init__(**kwargs) self.parity = parity self.mode = mode -class EdgePolicies(msrest.serialization.Model): +class EdgePolicies(_serialization.Model): """EdgePolicies. :ivar usage_data_collection_policy: @@ -3390,24 +3460,21 @@ class EdgePolicies(msrest.serialization.Model): """ _attribute_map = { - 'usage_data_collection_policy': {'key': 'usageDataCollectionPolicy', 'type': 'EdgeUsageDataCollectionPolicy'}, + "usage_data_collection_policy": {"key": "usageDataCollectionPolicy", "type": "EdgeUsageDataCollectionPolicy"}, } def __init__( - self, - *, - usage_data_collection_policy: Optional["_models.EdgeUsageDataCollectionPolicy"] = None, - **kwargs + self, *, usage_data_collection_policy: Optional["_models.EdgeUsageDataCollectionPolicy"] = None, **kwargs ): """ :keyword usage_data_collection_policy: :paramtype usage_data_collection_policy: ~azure.mgmt.media.models.EdgeUsageDataCollectionPolicy """ - super(EdgePolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.usage_data_collection_policy = usage_data_collection_policy -class EdgeUsageDataCollectionPolicy(msrest.serialization.Model): +class EdgeUsageDataCollectionPolicy(_serialization.Model): """EdgeUsageDataCollectionPolicy. :ivar data_collection_frequency: Usage data collection frequency in ISO 8601 duration format @@ -3424,10 +3491,10 @@ class EdgeUsageDataCollectionPolicy(msrest.serialization.Model): """ _attribute_map = { - 'data_collection_frequency': {'key': 'dataCollectionFrequency', 'type': 'str'}, - 'data_reporting_frequency': {'key': 'dataReportingFrequency', 'type': 'str'}, - 'max_allowed_unreported_usage_duration': {'key': 'maxAllowedUnreportedUsageDuration', 'type': 'str'}, - 'event_hub_details': {'key': 'eventHubDetails', 'type': 'EdgeUsageDataEventHub'}, + "data_collection_frequency": {"key": "dataCollectionFrequency", "type": "str"}, + "data_reporting_frequency": {"key": "dataReportingFrequency", "type": "str"}, + "max_allowed_unreported_usage_duration": {"key": "maxAllowedUnreportedUsageDuration", "type": "str"}, + "event_hub_details": {"key": "eventHubDetails", "type": "EdgeUsageDataEventHub"}, } def __init__( @@ -3452,14 +3519,14 @@ def __init__( :keyword event_hub_details: Details of Event Hub where the usage will be reported. :paramtype event_hub_details: ~azure.mgmt.media.models.EdgeUsageDataEventHub """ - super(EdgeUsageDataCollectionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.data_collection_frequency = data_collection_frequency self.data_reporting_frequency = data_reporting_frequency self.max_allowed_unreported_usage_duration = max_allowed_unreported_usage_duration self.event_hub_details = event_hub_details -class EdgeUsageDataEventHub(msrest.serialization.Model): +class EdgeUsageDataEventHub(_serialization.Model): """EdgeUsageDataEventHub. :ivar name: Name of the Event Hub where usage will be reported. @@ -3471,18 +3538,13 @@ class EdgeUsageDataEventHub(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "token": {"key": "token", "type": "str"}, } def __init__( - self, - *, - name: Optional[str] = None, - namespace: Optional[str] = None, - token: Optional[str] = None, - **kwargs + self, *, name: Optional[str] = None, namespace: Optional[str] = None, token: Optional[str] = None, **kwargs ): """ :keyword name: Name of the Event Hub where usage will be reported. @@ -3492,73 +3554,65 @@ def __init__( :keyword token: SAS token needed to interact with Event Hub. :paramtype token: str """ - super(EdgeUsageDataEventHub, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace self.token = token -class EnabledProtocols(msrest.serialization.Model): +class EnabledProtocols(_serialization.Model): """Class to specify which protocols are enabled. All required parameters must be populated in order to send to Azure. - :ivar download: Required. Enable Download protocol or not. + :ivar download: Enable Download protocol or not. Required. :vartype download: bool - :ivar dash: Required. Enable DASH protocol or not. + :ivar dash: Enable DASH protocol or not. Required. :vartype dash: bool - :ivar hls: Required. Enable HLS protocol or not. + :ivar hls: Enable HLS protocol or not. Required. :vartype hls: bool - :ivar smooth_streaming: Required. Enable SmoothStreaming protocol or not. + :ivar smooth_streaming: Enable SmoothStreaming protocol or not. Required. :vartype smooth_streaming: bool """ _validation = { - 'download': {'required': True}, - 'dash': {'required': True}, - 'hls': {'required': True}, - 'smooth_streaming': {'required': True}, + "download": {"required": True}, + "dash": {"required": True}, + "hls": {"required": True}, + "smooth_streaming": {"required": True}, } _attribute_map = { - 'download': {'key': 'download', 'type': 'bool'}, - 'dash': {'key': 'dash', 'type': 'bool'}, - 'hls': {'key': 'hls', 'type': 'bool'}, - 'smooth_streaming': {'key': 'smoothStreaming', 'type': 'bool'}, + "download": {"key": "download", "type": "bool"}, + "dash": {"key": "dash", "type": "bool"}, + "hls": {"key": "hls", "type": "bool"}, + "smooth_streaming": {"key": "smoothStreaming", "type": "bool"}, } - def __init__( - self, - *, - download: bool, - dash: bool, - hls: bool, - smooth_streaming: bool, - **kwargs - ): + def __init__(self, *, download: bool, dash: bool, hls: bool, smooth_streaming: bool, **kwargs): """ - :keyword download: Required. Enable Download protocol or not. + :keyword download: Enable Download protocol or not. Required. :paramtype download: bool - :keyword dash: Required. Enable DASH protocol or not. + :keyword dash: Enable DASH protocol or not. Required. :paramtype dash: bool - :keyword hls: Required. Enable HLS protocol or not. + :keyword hls: Enable HLS protocol or not. Required. :paramtype hls: bool - :keyword smooth_streaming: Required. Enable SmoothStreaming protocol or not. + :keyword smooth_streaming: Enable SmoothStreaming protocol or not. Required. :paramtype smooth_streaming: bool """ - super(EnabledProtocols, self).__init__(**kwargs) + super().__init__(**kwargs) self.download = download self.dash = dash self.hls = hls self.smooth_streaming = smooth_streaming -class EntityNameAvailabilityCheckOutput(msrest.serialization.Model): +class EntityNameAvailabilityCheckOutput(_serialization.Model): """The response from the check name availability request. All required parameters must be populated in order to send to Azure. - :ivar name_available: Required. Specifies if the name is available. + :ivar name_available: Specifies if the name is available. Required. :vartype name_available: bool :ivar reason: Specifies the reason if the name is not available. :vartype reason: str @@ -3567,38 +3621,31 @@ class EntityNameAvailabilityCheckOutput(msrest.serialization.Model): """ _validation = { - 'name_available': {'required': True}, + "name_available": {"required": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - name_available: bool, - reason: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name_available: bool, reason: Optional[str] = None, message: Optional[str] = None, **kwargs): """ - :keyword name_available: Required. Specifies if the name is available. + :keyword name_available: Specifies if the name is available. Required. :paramtype name_available: bool :keyword reason: Specifies the reason if the name is not available. :paramtype reason: str :keyword message: Specifies the detailed reason if the name is not available. :paramtype message: str """ - super(EntityNameAvailabilityCheckOutput, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class EnvelopeEncryption(msrest.serialization.Model): +class EnvelopeEncryption(_serialization.Model): """Class for EnvelopeEncryption encryption scheme. :ivar enabled_protocols: Representing supported protocols. @@ -3619,10 +3666,10 @@ class EnvelopeEncryption(msrest.serialization.Model): """ _attribute_map = { - 'enabled_protocols': {'key': 'enabledProtocols', 'type': 'EnabledProtocols'}, - 'clear_tracks': {'key': 'clearTracks', 'type': '[TrackSelection]'}, - 'content_keys': {'key': 'contentKeys', 'type': 'StreamingPolicyContentKeys'}, - 'custom_key_acquisition_url_template': {'key': 'customKeyAcquisitionUrlTemplate', 'type': 'str'}, + "enabled_protocols": {"key": "enabledProtocols", "type": "EnabledProtocols"}, + "clear_tracks": {"key": "clearTracks", "type": "[TrackSelection]"}, + "content_keys": {"key": "contentKeys", "type": "StreamingPolicyContentKeys"}, + "custom_key_acquisition_url_template": {"key": "customKeyAcquisitionUrlTemplate", "type": "str"}, } def __init__( @@ -3651,14 +3698,14 @@ def __init__( identifier of the key being requested. :paramtype custom_key_acquisition_url_template: str """ - super(EnvelopeEncryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled_protocols = enabled_protocols self.clear_tracks = clear_tracks self.content_keys = content_keys self.custom_key_acquisition_url_template = custom_key_acquisition_url_template -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -3666,31 +3713,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -3708,28 +3751,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -3737,7 +3776,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -3745,20 +3784,15 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.media.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error @@ -3767,7 +3801,7 @@ class FaceDetectorPreset(Preset): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar resolution: Specifies the maximum resolution at which your video is analyzed. The default behavior is "SourceResolution," which will keep the input video at its original resolution when @@ -3778,7 +3812,7 @@ class FaceDetectorPreset(Preset): video. It may also reduce the cost of using this component (see https://azure.microsoft.com/en-us/pricing/details/media-services/#analytics for details). However, faces that end up being too small in the resized video may not be detected. Known - values are: "SourceResolution", "StandardDefinition". + values are: "SourceResolution" and "StandardDefinition". :vartype resolution: str or ~azure.mgmt.media.models.AnalysisResolution :ivar mode: This mode provides the ability to choose between the following settings: 1) Analyze - For detection only.This mode generates a metadata JSON file marking appearances of faces @@ -3786,9 +3820,9 @@ class FaceDetectorPreset(Preset): 2) Combined - Additionally redacts(blurs) detected faces. 3) Redact - This enables a 2-pass process, allowing for selective redaction of a subset of detected faces.It takes in the metadata file from a prior analyze pass, along with the source video, and a user-selected - subset of IDs that require redaction. Known values are: "Analyze", "Redact", "Combined". + subset of IDs that require redaction. Known values are: "Analyze", "Redact", and "Combined". :vartype mode: str or ~azure.mgmt.media.models.FaceRedactorMode - :ivar blur_type: Blur type. Known values are: "Box", "Low", "Med", "High", "Black". + :ivar blur_type: Blur type. Known values are: "Box", "Low", "Med", "High", and "Black". :vartype blur_type: str or ~azure.mgmt.media.models.BlurType :ivar experimental_options: Dictionary containing key value pairs for parameters not exposed in the preset itself. @@ -3796,15 +3830,15 @@ class FaceDetectorPreset(Preset): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'resolution': {'key': 'resolution', 'type': 'str'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'blur_type': {'key': 'blurType', 'type': 'str'}, - 'experimental_options': {'key': 'experimentalOptions', 'type': '{str}'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "resolution": {"key": "resolution", "type": "str"}, + "mode": {"key": "mode", "type": "str"}, + "blur_type": {"key": "blurType", "type": "str"}, + "experimental_options": {"key": "experimentalOptions", "type": "{str}"}, } def __init__( @@ -3826,7 +3860,7 @@ def __init__( resolution video. It may also reduce the cost of using this component (see https://azure.microsoft.com/en-us/pricing/details/media-services/#analytics for details). However, faces that end up being too small in the resized video may not be detected. Known - values are: "SourceResolution", "StandardDefinition". + values are: "SourceResolution" and "StandardDefinition". :paramtype resolution: str or ~azure.mgmt.media.models.AnalysisResolution :keyword mode: This mode provides the ability to choose between the following settings: 1) Analyze - For detection only.This mode generates a metadata JSON file marking appearances of @@ -3834,29 +3868,29 @@ def __init__( ID. 2) Combined - Additionally redacts(blurs) detected faces. 3) Redact - This enables a 2-pass process, allowing for selective redaction of a subset of detected faces.It takes in the metadata file from a prior analyze pass, along with the source video, and a user-selected - subset of IDs that require redaction. Known values are: "Analyze", "Redact", "Combined". + subset of IDs that require redaction. Known values are: "Analyze", "Redact", and "Combined". :paramtype mode: str or ~azure.mgmt.media.models.FaceRedactorMode - :keyword blur_type: Blur type. Known values are: "Box", "Low", "Med", "High", "Black". + :keyword blur_type: Blur type. Known values are: "Box", "Low", "Med", "High", and "Black". :paramtype blur_type: str or ~azure.mgmt.media.models.BlurType :keyword experimental_options: Dictionary containing key value pairs for parameters not exposed in the preset itself. :paramtype experimental_options: dict[str, str] """ - super(FaceDetectorPreset, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.FaceDetectorPreset' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.FaceDetectorPreset" # type: str self.resolution = resolution self.mode = mode self.blur_type = blur_type self.experimental_options = experimental_options -class Filters(msrest.serialization.Model): +class Filters(_serialization.Model): """Describes all the filtering operations, such as de-interlacing, rotation etc. that are to be applied to the input media before encoding. :ivar deinterlace: The de-interlacing settings. :vartype deinterlace: ~azure.mgmt.media.models.Deinterlace :ivar rotation: The rotation, if any, to be applied to the input video, before it is encoded. - Default is Auto. Known values are: "Auto", "None", "Rotate0", "Rotate90", "Rotate180", + Default is Auto. Known values are: "Auto", "None", "Rotate0", "Rotate90", "Rotate180", and "Rotate270". :vartype rotation: str or ~azure.mgmt.media.models.Rotation :ivar crop: The parameters for the rectangular window with which to crop the input video. @@ -3867,10 +3901,10 @@ class Filters(msrest.serialization.Model): """ _attribute_map = { - 'deinterlace': {'key': 'deinterlace', 'type': 'Deinterlace'}, - 'rotation': {'key': 'rotation', 'type': 'str'}, - 'crop': {'key': 'crop', 'type': 'Rectangle'}, - 'overlays': {'key': 'overlays', 'type': '[Overlay]'}, + "deinterlace": {"key": "deinterlace", "type": "Deinterlace"}, + "rotation": {"key": "rotation", "type": "str"}, + "crop": {"key": "crop", "type": "Rectangle"}, + "overlays": {"key": "overlays", "type": "[Overlay]"}, } def __init__( @@ -3887,7 +3921,7 @@ def __init__( :paramtype deinterlace: ~azure.mgmt.media.models.Deinterlace :keyword rotation: The rotation, if any, to be applied to the input video, before it is encoded. Default is Auto. Known values are: "Auto", "None", "Rotate0", "Rotate90", "Rotate180", - "Rotate270". + and "Rotate270". :paramtype rotation: str or ~azure.mgmt.media.models.Rotation :keyword crop: The parameters for the rectangular window with which to crop the input video. :paramtype crop: ~azure.mgmt.media.models.Rectangle @@ -3895,38 +3929,38 @@ def __init__( audio, image or video overlays. :paramtype overlays: list[~azure.mgmt.media.models.Overlay] """ - super(Filters, self).__init__(**kwargs) + super().__init__(**kwargs) self.deinterlace = deinterlace self.rotation = rotation self.crop = crop self.overlays = overlays -class FilterTrackPropertyCondition(msrest.serialization.Model): +class FilterTrackPropertyCondition(_serialization.Model): """The class to specify one track property condition. All required parameters must be populated in order to send to Azure. - :ivar property: Required. The track property type. Known values are: "Unknown", "Type", "Name", - "Language", "FourCC", "Bitrate". + :ivar property: The track property type. Required. Known values are: "Unknown", "Type", "Name", + "Language", "FourCC", and "Bitrate". :vartype property: str or ~azure.mgmt.media.models.FilterTrackPropertyType - :ivar value: Required. The track property value. + :ivar value: The track property value. Required. :vartype value: str - :ivar operation: Required. The track property condition operation. Known values are: "Equal", - "NotEqual". + :ivar operation: The track property condition operation. Required. Known values are: "Equal" + and "NotEqual". :vartype operation: str or ~azure.mgmt.media.models.FilterTrackPropertyCompareOperation """ _validation = { - 'property': {'required': True}, - 'value': {'required': True}, - 'operation': {'required': True}, + "property": {"required": True}, + "value": {"required": True}, + "operation": {"required": True}, } _attribute_map = { - 'property': {'key': 'property', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "property": {"key": "property", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -3938,154 +3972,141 @@ def __init__( **kwargs ): """ - :keyword property: Required. The track property type. Known values are: "Unknown", "Type", - "Name", "Language", "FourCC", "Bitrate". + :keyword property: The track property type. Required. Known values are: "Unknown", "Type", + "Name", "Language", "FourCC", and "Bitrate". :paramtype property: str or ~azure.mgmt.media.models.FilterTrackPropertyType - :keyword value: Required. The track property value. + :keyword value: The track property value. Required. :paramtype value: str - :keyword operation: Required. The track property condition operation. Known values are: - "Equal", "NotEqual". + :keyword operation: The track property condition operation. Required. Known values are: "Equal" + and "NotEqual". :paramtype operation: str or ~azure.mgmt.media.models.FilterTrackPropertyCompareOperation """ - super(FilterTrackPropertyCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.property = property self.value = value self.operation = operation -class FilterTrackSelection(msrest.serialization.Model): +class FilterTrackSelection(_serialization.Model): """Representing a list of FilterTrackPropertyConditions to select a track. The filters are combined using a logical AND operation. All required parameters must be populated in order to send to Azure. - :ivar track_selections: Required. The track selections. + :ivar track_selections: The track selections. Required. :vartype track_selections: list[~azure.mgmt.media.models.FilterTrackPropertyCondition] """ _validation = { - 'track_selections': {'required': True}, + "track_selections": {"required": True}, } _attribute_map = { - 'track_selections': {'key': 'trackSelections', 'type': '[FilterTrackPropertyCondition]'}, + "track_selections": {"key": "trackSelections", "type": "[FilterTrackPropertyCondition]"}, } - def __init__( - self, - *, - track_selections: List["_models.FilterTrackPropertyCondition"], - **kwargs - ): + def __init__(self, *, track_selections: List["_models.FilterTrackPropertyCondition"], **kwargs): """ - :keyword track_selections: Required. The track selections. + :keyword track_selections: The track selections. Required. :paramtype track_selections: list[~azure.mgmt.media.models.FilterTrackPropertyCondition] """ - super(FilterTrackSelection, self).__init__(**kwargs) + super().__init__(**kwargs) self.track_selections = track_selections -class FirstQuality(msrest.serialization.Model): +class FirstQuality(_serialization.Model): """Filter First Quality. All required parameters must be populated in order to send to Azure. - :ivar bitrate: Required. The first quality bitrate. + :ivar bitrate: The first quality bitrate. Required. :vartype bitrate: int """ _validation = { - 'bitrate': {'required': True}, + "bitrate": {"required": True}, } _attribute_map = { - 'bitrate': {'key': 'bitrate', 'type': 'int'}, + "bitrate": {"key": "bitrate", "type": "int"}, } - def __init__( - self, - *, - bitrate: int, - **kwargs - ): + def __init__(self, *, bitrate: int, **kwargs): """ - :keyword bitrate: Required. The first quality bitrate. + :keyword bitrate: The first quality bitrate. Required. :paramtype bitrate: int """ - super(FirstQuality, self).__init__(**kwargs) + super().__init__(**kwargs) self.bitrate = bitrate -class Format(msrest.serialization.Model): +class Format(_serialization.Model): """Base class for output. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageFormat, MultiBitrateFormat. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ImageFormat, MultiBitrateFormat All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.ImageFormat': 'ImageFormat', '#Microsoft.Media.MultiBitrateFormat': 'MultiBitrateFormat'} - } - - def __init__( - self, - *, - filename_pattern: str, - **kwargs - ): - """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + "odata_type": { + "#Microsoft.Media.ImageFormat": "ImageFormat", + "#Microsoft.Media.MultiBitrateFormat": "MultiBitrateFormat", + } + } + + def __init__(self, *, filename_pattern: str, **kwargs): + """ + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str """ - super(Format, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.filename_pattern = filename_pattern -class InputDefinition(msrest.serialization.Model): +class InputDefinition(_serialization.Model): """Base class for defining an input. Use sub classes of this class to specify tracks selections and related metadata. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FromAllInputFile, FromEachInputFile, InputFile. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FromAllInputFile, FromEachInputFile, InputFile All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. @@ -4093,30 +4114,29 @@ class InputDefinition(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'included_tracks': {'key': 'includedTracks', 'type': '[TrackDescriptor]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "included_tracks": {"key": "includedTracks", "type": "[TrackDescriptor]"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.FromAllInputFile': 'FromAllInputFile', '#Microsoft.Media.FromEachInputFile': 'FromEachInputFile', '#Microsoft.Media.InputFile': 'InputFile'} + "odata_type": { + "#Microsoft.Media.FromAllInputFile": "FromAllInputFile", + "#Microsoft.Media.FromEachInputFile": "FromEachInputFile", + "#Microsoft.Media.InputFile": "InputFile", + } } - def __init__( - self, - *, - included_tracks: Optional[List["_models.TrackDescriptor"]] = None, - **kwargs - ): + def __init__(self, *, included_tracks: Optional[List["_models.TrackDescriptor"]] = None, **kwargs): """ :keyword included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. :paramtype included_tracks: list[~azure.mgmt.media.models.TrackDescriptor] """ - super(InputDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.included_tracks = included_tracks @@ -4126,7 +4146,7 @@ class FromAllInputFile(InputDefinition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. @@ -4134,27 +4154,22 @@ class FromAllInputFile(InputDefinition): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'included_tracks': {'key': 'includedTracks', 'type': '[TrackDescriptor]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "included_tracks": {"key": "includedTracks", "type": "[TrackDescriptor]"}, } - def __init__( - self, - *, - included_tracks: Optional[List["_models.TrackDescriptor"]] = None, - **kwargs - ): + def __init__(self, *, included_tracks: Optional[List["_models.TrackDescriptor"]] = None, **kwargs): """ :keyword included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. :paramtype included_tracks: list[~azure.mgmt.media.models.TrackDescriptor] """ - super(FromAllInputFile, self).__init__(included_tracks=included_tracks, **kwargs) - self.odata_type = '#Microsoft.Media.FromAllInputFile' # type: str + super().__init__(included_tracks=included_tracks, **kwargs) + self.odata_type = "#Microsoft.Media.FromAllInputFile" # type: str class FromEachInputFile(InputDefinition): @@ -4162,7 +4177,7 @@ class FromEachInputFile(InputDefinition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. @@ -4170,30 +4185,25 @@ class FromEachInputFile(InputDefinition): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'included_tracks': {'key': 'includedTracks', 'type': '[TrackDescriptor]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "included_tracks": {"key": "includedTracks", "type": "[TrackDescriptor]"}, } - def __init__( - self, - *, - included_tracks: Optional[List["_models.TrackDescriptor"]] = None, - **kwargs - ): + def __init__(self, *, included_tracks: Optional[List["_models.TrackDescriptor"]] = None, **kwargs): """ :keyword included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. :paramtype included_tracks: list[~azure.mgmt.media.models.TrackDescriptor] """ - super(FromEachInputFile, self).__init__(included_tracks=included_tracks, **kwargs) - self.odata_type = '#Microsoft.Media.FromEachInputFile' # type: str + super().__init__(included_tracks=included_tracks, **kwargs) + self.odata_type = "#Microsoft.Media.FromEachInputFile" # type: str -class Layer(msrest.serialization.Model): +class Layer(_serialization.Model): """The encoder can be configured to produce video and/or images (thumbnails) at different resolutions, by specifying a layer for each desired resolution. A layer represents the properties for the video or image at a resolution. :ivar width: The width of the output video for this layer. The value can be absolute (in @@ -4210,18 +4220,13 @@ class Layer(msrest.serialization.Model): """ _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, } def __init__( - self, - *, - width: Optional[str] = None, - height: Optional[str] = None, - label: Optional[str] = None, - **kwargs + self, *, width: Optional[str] = None, height: Optional[str] = None, label: Optional[str] = None, **kwargs ): """ :keyword width: The width of the output video for this layer. The value can be absolute (in @@ -4236,7 +4241,7 @@ def __init__( different video and audio layers, or in naming the output file. :paramtype label: str """ - super(Layer, self).__init__(**kwargs) + super().__init__(**kwargs) self.width = width self.height = height self.label = label @@ -4258,8 +4263,8 @@ class VideoLayer(Layer): :ivar label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :vartype label: str - :ivar bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. This is a required field. + :ivar bitrate: The average bitrate in bits per second at which to encode the input video when + generating this layer. This is a required field. Required. :vartype bitrate: int :ivar max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4283,19 +4288,19 @@ class VideoLayer(Layer): """ _validation = { - 'bitrate': {'required': True}, + "bitrate": {"required": True}, } _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'bitrate': {'key': 'bitrate', 'type': 'int'}, - 'max_bitrate': {'key': 'maxBitrate', 'type': 'int'}, - 'b_frames': {'key': 'bFrames', 'type': 'int'}, - 'frame_rate': {'key': 'frameRate', 'type': 'str'}, - 'slices': {'key': 'slices', 'type': 'int'}, - 'adaptive_b_frame': {'key': 'adaptiveBFrame', 'type': 'bool'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "bitrate": {"key": "bitrate", "type": "int"}, + "max_bitrate": {"key": "maxBitrate", "type": "int"}, + "b_frames": {"key": "bFrames", "type": "int"}, + "frame_rate": {"key": "frameRate", "type": "str"}, + "slices": {"key": "slices", "type": "int"}, + "adaptive_b_frame": {"key": "adaptiveBFrame", "type": "bool"}, } def __init__( @@ -4324,8 +4329,8 @@ def __init__( :keyword label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :paramtype label: str - :keyword bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. This is a required field. + :keyword bitrate: The average bitrate in bits per second at which to encode the input video + when generating this layer. This is a required field. Required. :paramtype bitrate: int :keyword max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4347,7 +4352,7 @@ def __init__( use. :paramtype adaptive_b_frame: bool """ - super(VideoLayer, self).__init__(width=width, height=height, label=label, **kwargs) + super().__init__(width=width, height=height, label=label, **kwargs) self.bitrate = bitrate self.max_bitrate = max_bitrate self.b_frames = b_frames @@ -4356,7 +4361,7 @@ def __init__( self.adaptive_b_frame = adaptive_b_frame -class H264Layer(VideoLayer): +class H264Layer(VideoLayer): # pylint: disable=too-many-instance-attributes """Describes the settings to be used when encoding the input video into a desired output bitrate layer with the H.264 video codec. All required parameters must be populated in order to send to Azure. @@ -4372,8 +4377,8 @@ class H264Layer(VideoLayer): :ivar label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :vartype label: str - :ivar bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. This is a required field. + :ivar bitrate: The average bitrate in bits per second at which to encode the input video when + generating this layer. This is a required field. Required. :vartype bitrate: int :ivar max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4395,7 +4400,7 @@ class H264Layer(VideoLayer): use. :vartype adaptive_b_frame: bool :ivar profile: We currently support Baseline, Main, High, High422, High444. Default is Auto. - Known values are: "Auto", "Baseline", "Main", "High", "High422", "High444". + Known values are: "Auto", "Baseline", "Main", "High", "High422", and "High444". :vartype profile: str or ~azure.mgmt.media.models.H264VideoProfile :ivar level: We currently support Level up to 6.2. The value can be Auto, or a number that matches the H.264 profile. If not specified, the default is Auto, which lets the encoder choose @@ -4415,31 +4420,31 @@ class H264Layer(VideoLayer): setting. :vartype reference_frames: int :ivar entropy_mode: The entropy mode to be used for this layer. If not specified, the encoder - chooses the mode that is appropriate for the profile and level. Known values are: "Cabac", + chooses the mode that is appropriate for the profile and level. Known values are: "Cabac" and "Cavlc". :vartype entropy_mode: str or ~azure.mgmt.media.models.EntropyMode """ _validation = { - 'bitrate': {'required': True}, + "bitrate": {"required": True}, } _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'bitrate': {'key': 'bitrate', 'type': 'int'}, - 'max_bitrate': {'key': 'maxBitrate', 'type': 'int'}, - 'b_frames': {'key': 'bFrames', 'type': 'int'}, - 'frame_rate': {'key': 'frameRate', 'type': 'str'}, - 'slices': {'key': 'slices', 'type': 'int'}, - 'adaptive_b_frame': {'key': 'adaptiveBFrame', 'type': 'bool'}, - 'profile': {'key': 'profile', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'buffer_window': {'key': 'bufferWindow', 'type': 'duration'}, - 'crf': {'key': 'crf', 'type': 'float'}, - 'reference_frames': {'key': 'referenceFrames', 'type': 'int'}, - 'entropy_mode': {'key': 'entropyMode', 'type': 'str'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "bitrate": {"key": "bitrate", "type": "int"}, + "max_bitrate": {"key": "maxBitrate", "type": "int"}, + "b_frames": {"key": "bFrames", "type": "int"}, + "frame_rate": {"key": "frameRate", "type": "str"}, + "slices": {"key": "slices", "type": "int"}, + "adaptive_b_frame": {"key": "adaptiveBFrame", "type": "bool"}, + "profile": {"key": "profile", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "buffer_window": {"key": "bufferWindow", "type": "duration"}, + "crf": {"key": "crf", "type": "float"}, + "reference_frames": {"key": "referenceFrames", "type": "int"}, + "entropy_mode": {"key": "entropyMode", "type": "str"}, } def __init__( @@ -4474,8 +4479,8 @@ def __init__( :keyword label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :paramtype label: str - :keyword bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. This is a required field. + :keyword bitrate: The average bitrate in bits per second at which to encode the input video + when generating this layer. This is a required field. Required. :paramtype bitrate: int :keyword max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4497,7 +4502,7 @@ def __init__( use. :paramtype adaptive_b_frame: bool :keyword profile: We currently support Baseline, Main, High, High422, High444. Default is Auto. - Known values are: "Auto", "Baseline", "Main", "High", "High422", "High444". + Known values are: "Auto", "Baseline", "Main", "High", "High422", and "High444". :paramtype profile: str or ~azure.mgmt.media.models.H264VideoProfile :keyword level: We currently support Level up to 6.2. The value can be Auto, or a number that matches the H.264 profile. If not specified, the default is Auto, which lets the encoder choose @@ -4519,10 +4524,21 @@ def __init__( :paramtype reference_frames: int :keyword entropy_mode: The entropy mode to be used for this layer. If not specified, the encoder chooses the mode that is appropriate for the profile and level. Known values are: - "Cabac", "Cavlc". + "Cabac" and "Cavlc". :paramtype entropy_mode: str or ~azure.mgmt.media.models.EntropyMode """ - super(H264Layer, self).__init__(width=width, height=height, label=label, bitrate=bitrate, max_bitrate=max_bitrate, b_frames=b_frames, frame_rate=frame_rate, slices=slices, adaptive_b_frame=adaptive_b_frame, **kwargs) + super().__init__( + width=width, + height=height, + label=label, + bitrate=bitrate, + max_bitrate=max_bitrate, + b_frames=b_frames, + frame_rate=frame_rate, + slices=slices, + adaptive_b_frame=adaptive_b_frame, + **kwargs + ) self.profile = profile self.level = level self.buffer_window = buffer_window @@ -4534,12 +4550,12 @@ def __init__( class Video(Codec): """Describes the basic properties for encoding the input video. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: H264Video, H265Video, Image. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + H264Video, H265Video, Image All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -4549,26 +4565,31 @@ class Video(Codec): value will follow the input source setting. :vartype key_frame_interval: ~datetime.timedelta :ivar stretch_mode: The resizing mode - how the input video will be resized to fit the desired - output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", "AutoFit". + output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :vartype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "sync_mode": {"key": "syncMode", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.H264Video': 'H264Video', '#Microsoft.Media.H265Video': 'H265Video', '#Microsoft.Media.Image': 'Image'} + "odata_type": { + "#Microsoft.Media.H264Video": "H264Video", + "#Microsoft.Media.H265Video": "H265Video", + "#Microsoft.Media.Image": "Image", + } } def __init__( @@ -4590,14 +4611,15 @@ def __init__( KeyFrameInterval value will follow the input source setting. :paramtype key_frame_interval: ~datetime.timedelta :keyword stretch_mode: The resizing mode - how the input video will be resized to fit the - desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", + desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :paramtype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode """ - super(Video, self).__init__(label=label, **kwargs) - self.odata_type = '#Microsoft.Media.Video' # type: str + super().__init__(label=label, **kwargs) + self.odata_type = "#Microsoft.Media.Video" # type: str self.key_frame_interval = key_frame_interval self.stretch_mode = stretch_mode self.sync_mode = sync_mode @@ -4608,7 +4630,7 @@ class H264Video(Video): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -4618,16 +4640,18 @@ class H264Video(Video): value will follow the input source setting. :vartype key_frame_interval: ~datetime.timedelta :ivar stretch_mode: The resizing mode - how the input video will be resized to fit the desired - output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", "AutoFit". + output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :vartype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode :ivar complexity: Tells the encoder how to choose its encoding settings. The default value is - Balanced. Known values are: "Speed", "Balanced", "Quality". + Balanced. Known values are: "Speed", "Balanced", and "Quality". :vartype complexity: str or ~azure.mgmt.media.models.H264Complexity :ivar layers: The collection of output H.264 layers to be produced by the encoder. :vartype layers: list[~azure.mgmt.media.models.H264Layer] - :ivar rate_control_mode: The video rate control mode. Known values are: "ABR", "CBR", "CRF". + :ivar rate_control_mode: The video rate control mode. Known values are: "ABR", "CBR", and + "CRF". :vartype rate_control_mode: str or ~azure.mgmt.media.models.H264RateControlMode :ivar scene_change_detection: Whether or not the encoder should insert key frames at scene changes. If not specified, the default is false. This flag should be set to true only when the @@ -4636,19 +4660,19 @@ class H264Video(Video): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, - 'complexity': {'key': 'complexity', 'type': 'str'}, - 'layers': {'key': 'layers', 'type': '[H264Layer]'}, - 'rate_control_mode': {'key': 'rateControlMode', 'type': 'str'}, - 'scene_change_detection': {'key': 'sceneChangeDetection', 'type': 'bool'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "sync_mode": {"key": "syncMode", "type": "str"}, + "complexity": {"key": "complexity", "type": "str"}, + "layers": {"key": "layers", "type": "[H264Layer]"}, + "rate_control_mode": {"key": "rateControlMode", "type": "str"}, + "scene_change_detection": {"key": "sceneChangeDetection", "type": "bool"}, } def __init__( @@ -4674,25 +4698,29 @@ def __init__( KeyFrameInterval value will follow the input source setting. :paramtype key_frame_interval: ~datetime.timedelta :keyword stretch_mode: The resizing mode - how the input video will be resized to fit the - desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", + desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :paramtype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode :keyword complexity: Tells the encoder how to choose its encoding settings. The default value - is Balanced. Known values are: "Speed", "Balanced", "Quality". + is Balanced. Known values are: "Speed", "Balanced", and "Quality". :paramtype complexity: str or ~azure.mgmt.media.models.H264Complexity :keyword layers: The collection of output H.264 layers to be produced by the encoder. :paramtype layers: list[~azure.mgmt.media.models.H264Layer] - :keyword rate_control_mode: The video rate control mode. Known values are: "ABR", "CBR", "CRF". + :keyword rate_control_mode: The video rate control mode. Known values are: "ABR", "CBR", and + "CRF". :paramtype rate_control_mode: str or ~azure.mgmt.media.models.H264RateControlMode :keyword scene_change_detection: Whether or not the encoder should insert key frames at scene changes. If not specified, the default is false. This flag should be set to true only when the encoder is being configured to produce a single output video. :paramtype scene_change_detection: bool """ - super(H264Video, self).__init__(label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, **kwargs) - self.odata_type = '#Microsoft.Media.H264Video' # type: str + super().__init__( + label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, **kwargs + ) + self.odata_type = "#Microsoft.Media.H264Video" # type: str self.complexity = complexity self.layers = layers self.rate_control_mode = rate_control_mode @@ -4715,9 +4743,9 @@ class H265VideoLayer(Layer): :ivar label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :vartype label: str - :ivar bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this - value should be 3000000 This is a required field. + :ivar bitrate: The average bitrate in bits per second at which to encode the input video when + generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this value + should be 3000000 This is a required field. Required. :vartype bitrate: int :ivar max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4741,19 +4769,19 @@ class H265VideoLayer(Layer): """ _validation = { - 'bitrate': {'required': True}, + "bitrate": {"required": True}, } _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'bitrate': {'key': 'bitrate', 'type': 'int'}, - 'max_bitrate': {'key': 'maxBitrate', 'type': 'int'}, - 'b_frames': {'key': 'bFrames', 'type': 'int'}, - 'frame_rate': {'key': 'frameRate', 'type': 'str'}, - 'slices': {'key': 'slices', 'type': 'int'}, - 'adaptive_b_frame': {'key': 'adaptiveBFrame', 'type': 'bool'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "bitrate": {"key": "bitrate", "type": "int"}, + "max_bitrate": {"key": "maxBitrate", "type": "int"}, + "b_frames": {"key": "bFrames", "type": "int"}, + "frame_rate": {"key": "frameRate", "type": "str"}, + "slices": {"key": "slices", "type": "int"}, + "adaptive_b_frame": {"key": "adaptiveBFrame", "type": "bool"}, } def __init__( @@ -4782,9 +4810,9 @@ def __init__( :keyword label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :paramtype label: str - :keyword bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this - value should be 3000000 This is a required field. + :keyword bitrate: The average bitrate in bits per second at which to encode the input video + when generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this value + should be 3000000 This is a required field. Required. :paramtype bitrate: int :keyword max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4806,7 +4834,7 @@ def __init__( permits its use. :paramtype adaptive_b_frame: bool """ - super(H265VideoLayer, self).__init__(width=width, height=height, label=label, **kwargs) + super().__init__(width=width, height=height, label=label, **kwargs) self.bitrate = bitrate self.max_bitrate = max_bitrate self.b_frames = b_frames @@ -4815,7 +4843,7 @@ def __init__( self.adaptive_b_frame = adaptive_b_frame -class H265Layer(H265VideoLayer): +class H265Layer(H265VideoLayer): # pylint: disable=too-many-instance-attributes """Describes the settings to be used when encoding the input video into a desired output bitrate layer with the H.265 video codec. All required parameters must be populated in order to send to Azure. @@ -4831,9 +4859,9 @@ class H265Layer(H265VideoLayer): :ivar label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :vartype label: str - :ivar bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this - value should be 3000000 This is a required field. + :ivar bitrate: The average bitrate in bits per second at which to encode the input video when + generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this value + should be 3000000 This is a required field. Required. :vartype bitrate: int :ivar max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4855,7 +4883,7 @@ class H265Layer(H265VideoLayer): its use. :vartype adaptive_b_frame: bool :ivar profile: We currently support Main. Default is Auto. Known values are: "Auto", "Main", - "Main10". + and "Main10". :vartype profile: str or ~azure.mgmt.media.models.H265VideoProfile :ivar level: We currently support Level up to 6.2. The value can be Auto, or a number that matches the H.265 profile. If not specified, the default is Auto, which lets the encoder choose @@ -4877,24 +4905,24 @@ class H265Layer(H265VideoLayer): """ _validation = { - 'bitrate': {'required': True}, + "bitrate": {"required": True}, } _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'bitrate': {'key': 'bitrate', 'type': 'int'}, - 'max_bitrate': {'key': 'maxBitrate', 'type': 'int'}, - 'b_frames': {'key': 'bFrames', 'type': 'int'}, - 'frame_rate': {'key': 'frameRate', 'type': 'str'}, - 'slices': {'key': 'slices', 'type': 'int'}, - 'adaptive_b_frame': {'key': 'adaptiveBFrame', 'type': 'bool'}, - 'profile': {'key': 'profile', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'buffer_window': {'key': 'bufferWindow', 'type': 'duration'}, - 'crf': {'key': 'crf', 'type': 'float'}, - 'reference_frames': {'key': 'referenceFrames', 'type': 'int'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "bitrate": {"key": "bitrate", "type": "int"}, + "max_bitrate": {"key": "maxBitrate", "type": "int"}, + "b_frames": {"key": "bFrames", "type": "int"}, + "frame_rate": {"key": "frameRate", "type": "str"}, + "slices": {"key": "slices", "type": "int"}, + "adaptive_b_frame": {"key": "adaptiveBFrame", "type": "bool"}, + "profile": {"key": "profile", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "buffer_window": {"key": "bufferWindow", "type": "duration"}, + "crf": {"key": "crf", "type": "float"}, + "reference_frames": {"key": "referenceFrames", "type": "int"}, } def __init__( @@ -4928,9 +4956,9 @@ def __init__( :keyword label: The alphanumeric label for this layer, which can be used in multiplexing different video and audio layers, or in naming the output file. :paramtype label: str - :keyword bitrate: Required. The average bitrate in bits per second at which to encode the input - video when generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this - value should be 3000000 This is a required field. + :keyword bitrate: The average bitrate in bits per second at which to encode the input video + when generating this layer. For example: a target bitrate of 3000Kbps or 3Mbps means this value + should be 3000000 This is a required field. Required. :paramtype bitrate: int :keyword max_bitrate: The maximum bitrate (in bits per second), at which the VBV buffer should be assumed to refill. If not specified, defaults to the same value as bitrate. @@ -4952,7 +4980,7 @@ def __init__( permits its use. :paramtype adaptive_b_frame: bool :keyword profile: We currently support Main. Default is Auto. Known values are: "Auto", "Main", - "Main10". + and "Main10". :paramtype profile: str or ~azure.mgmt.media.models.H265VideoProfile :keyword level: We currently support Level up to 6.2. The value can be Auto, or a number that matches the H.265 profile. If not specified, the default is Auto, which lets the encoder choose @@ -4973,7 +5001,18 @@ def __init__( setting. :paramtype reference_frames: int """ - super(H265Layer, self).__init__(width=width, height=height, label=label, bitrate=bitrate, max_bitrate=max_bitrate, b_frames=b_frames, frame_rate=frame_rate, slices=slices, adaptive_b_frame=adaptive_b_frame, **kwargs) + super().__init__( + width=width, + height=height, + label=label, + bitrate=bitrate, + max_bitrate=max_bitrate, + b_frames=b_frames, + frame_rate=frame_rate, + slices=slices, + adaptive_b_frame=adaptive_b_frame, + **kwargs + ) self.profile = profile self.level = level self.buffer_window = buffer_window @@ -4986,7 +5025,7 @@ class H265Video(Video): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -4996,9 +5035,10 @@ class H265Video(Video): value will follow the input source setting. :vartype key_frame_interval: ~datetime.timedelta :ivar stretch_mode: The resizing mode - how the input video will be resized to fit the desired - output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", "AutoFit". + output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :vartype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode :ivar scene_change_detection: Specifies whether or not the encoder should insert key frames at scene changes. If not specified, the default is false. This flag should be set to true only @@ -5007,25 +5047,25 @@ class H265Video(Video): :ivar complexity: Tells the encoder how to choose its encoding settings. Quality will provide for a higher compression ratio but at a higher cost and longer compute time. Speed will produce a relatively larger file but is faster and more economical. The default value is - Balanced. Known values are: "Speed", "Balanced", "Quality". + Balanced. Known values are: "Speed", "Balanced", and "Quality". :vartype complexity: str or ~azure.mgmt.media.models.H265Complexity :ivar layers: The collection of output H.265 layers to be produced by the encoder. :vartype layers: list[~azure.mgmt.media.models.H265Layer] """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, - 'scene_change_detection': {'key': 'sceneChangeDetection', 'type': 'bool'}, - 'complexity': {'key': 'complexity', 'type': 'str'}, - 'layers': {'key': 'layers', 'type': '[H265Layer]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "sync_mode": {"key": "syncMode", "type": "str"}, + "scene_change_detection": {"key": "sceneChangeDetection", "type": "bool"}, + "complexity": {"key": "complexity", "type": "str"}, + "layers": {"key": "layers", "type": "[H265Layer]"}, } def __init__( @@ -5050,10 +5090,11 @@ def __init__( KeyFrameInterval value will follow the input source setting. :paramtype key_frame_interval: ~datetime.timedelta :keyword stretch_mode: The resizing mode - how the input video will be resized to fit the - desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", + desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :paramtype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode :keyword scene_change_detection: Specifies whether or not the encoder should insert key frames at scene changes. If not specified, the default is false. This flag should be set to true only @@ -5062,19 +5103,21 @@ def __init__( :keyword complexity: Tells the encoder how to choose its encoding settings. Quality will provide for a higher compression ratio but at a higher cost and longer compute time. Speed will produce a relatively larger file but is faster and more economical. The default value is - Balanced. Known values are: "Speed", "Balanced", "Quality". + Balanced. Known values are: "Speed", "Balanced", and "Quality". :paramtype complexity: str or ~azure.mgmt.media.models.H265Complexity :keyword layers: The collection of output H.265 layers to be produced by the encoder. :paramtype layers: list[~azure.mgmt.media.models.H265Layer] """ - super(H265Video, self).__init__(label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, **kwargs) - self.odata_type = '#Microsoft.Media.H265Video' # type: str + super().__init__( + label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, **kwargs + ) + self.odata_type = "#Microsoft.Media.H265Video" # type: str self.scene_change_detection = scene_change_detection self.complexity = complexity self.layers = layers -class Hls(msrest.serialization.Model): +class Hls(_serialization.Model): """HTTP Live Streaming (HLS) packing setting for the live output. :ivar fragments_per_ts_segment: The number of fragments in an HTTP Live Streaming (HLS) TS @@ -5084,27 +5127,22 @@ class Hls(msrest.serialization.Model): """ _attribute_map = { - 'fragments_per_ts_segment': {'key': 'fragmentsPerTsSegment', 'type': 'int'}, + "fragments_per_ts_segment": {"key": "fragmentsPerTsSegment", "type": "int"}, } - def __init__( - self, - *, - fragments_per_ts_segment: Optional[int] = None, - **kwargs - ): + def __init__(self, *, fragments_per_ts_segment: Optional[int] = None, **kwargs): """ :keyword fragments_per_ts_segment: The number of fragments in an HTTP Live Streaming (HLS) TS segment in the output of the live event. This value does not affect the packing ratio for HLS CMAF output. :paramtype fragments_per_ts_segment: int """ - super(Hls, self).__init__(**kwargs) + super().__init__(**kwargs) self.fragments_per_ts_segment = fragments_per_ts_segment -class HlsSettings(msrest.serialization.Model): - """The HLS setting for a text track. +class HlsSettings(_serialization.Model): + """The HLS setting for a track. :ivar default: The default for the HLS setting. :vartype default: bool @@ -5115,9 +5153,9 @@ class HlsSettings(msrest.serialization.Model): """ _attribute_map = { - 'default': {'key': 'default', 'type': 'bool'}, - 'forced': {'key': 'forced', 'type': 'bool'}, - 'characteristics': {'key': 'characteristics', 'type': 'str'}, + "default": {"key": "default", "type": "bool"}, + "forced": {"key": "forced", "type": "bool"}, + "characteristics": {"key": "characteristics", "type": "str"}, } def __init__( @@ -5136,7 +5174,7 @@ def __init__( :keyword characteristics: The characteristics for the HLS setting. :paramtype characteristics: str """ - super(HlsSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.default = default self.forced = forced self.characteristics = characteristics @@ -5145,12 +5183,12 @@ def __init__( class Image(Video): """Describes the basic properties for generating thumbnails from the input video. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JpgImage, PngImage. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JpgImage, PngImage All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -5160,17 +5198,18 @@ class Image(Video): value will follow the input source setting. :vartype key_frame_interval: ~datetime.timedelta :ivar stretch_mode: The resizing mode - how the input video will be resized to fit the desired - output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", "AutoFit". + output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :vartype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode - :ivar start: Required. The position in the input video from where to start generating - thumbnails. The value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or - a frame count (For example, 10 to start at the 10th frame), or a relative value to stream - duration (For example, 10% to start at 10% of stream duration). Also supports a macro {Best}, - which tells the encoder to select the best thumbnail from the first few seconds of the video - and will only produce one thumbnail, no matter what other settings are for Step and Range. The - default value is macro {Best}. + :ivar start: The position in the input video from where to start generating thumbnails. The + value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or a frame count + (For example, 10 to start at the 10th frame), or a relative value to stream duration (For + example, 10% to start at 10% of stream duration). Also supports a macro {Best}, which tells the + encoder to select the best thumbnail from the first few seconds of the video and will only + produce one thumbnail, no matter what other settings are for Step and Range. The default value + is macro {Best}. Required. :vartype start: str :ivar step: The intervals at which thumbnails are generated. The value can be in ISO 8601 format (For example, PT05S for one image every 5 seconds), or a frame count (For example, 30 @@ -5194,24 +5233,22 @@ class Image(Video): """ _validation = { - 'odata_type': {'required': True}, - 'start': {'required': True}, + "odata_type": {"required": True}, + "start": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'str'}, - 'step': {'key': 'step', 'type': 'str'}, - 'range': {'key': 'range', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "sync_mode": {"key": "syncMode", "type": "str"}, + "start": {"key": "start", "type": "str"}, + "step": {"key": "step", "type": "str"}, + "range": {"key": "range", "type": "str"}, } - _subtype_map = { - 'odata_type': {'#Microsoft.Media.JpgImage': 'JpgImage', '#Microsoft.Media.PngImage': 'PngImage'} - } + _subtype_map = {"odata_type": {"#Microsoft.Media.JpgImage": "JpgImage", "#Microsoft.Media.PngImage": "PngImage"}} def __init__( self, @@ -5235,18 +5272,19 @@ def __init__( KeyFrameInterval value will follow the input source setting. :paramtype key_frame_interval: ~datetime.timedelta :keyword stretch_mode: The resizing mode - how the input video will be resized to fit the - desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", + desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :paramtype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode - :keyword start: Required. The position in the input video from where to start generating - thumbnails. The value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or - a frame count (For example, 10 to start at the 10th frame), or a relative value to stream - duration (For example, 10% to start at 10% of stream duration). Also supports a macro {Best}, - which tells the encoder to select the best thumbnail from the first few seconds of the video - and will only produce one thumbnail, no matter what other settings are for Step and Range. The - default value is macro {Best}. + :keyword start: The position in the input video from where to start generating thumbnails. The + value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or a frame count + (For example, 10 to start at the 10th frame), or a relative value to stream duration (For + example, 10% to start at 10% of stream duration). Also supports a macro {Best}, which tells the + encoder to select the best thumbnail from the first few seconds of the video and will only + produce one thumbnail, no matter what other settings are for Step and Range. The default value + is macro {Best}. Required. :paramtype start: str :keyword step: The intervals at which thumbnails are generated. The value can be in ISO 8601 format (For example, PT05S for one image every 5 seconds), or a frame count (For example, 30 @@ -5268,8 +5306,10 @@ def __init__( which means to stop at the end of the stream. :paramtype range: str """ - super(Image, self).__init__(label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, **kwargs) - self.odata_type = '#Microsoft.Media.Image' # type: str + super().__init__( + label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, **kwargs + ) + self.odata_type = "#Microsoft.Media.Image" # type: str self.start = start self.step = step self.range = range @@ -5278,62 +5318,56 @@ def __init__( class ImageFormat(Format): """Describes the properties for an output image file. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JpgFormat, PngFormat. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JpgFormat, PngFormat All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.JpgFormat': 'JpgFormat', '#Microsoft.Media.PngFormat': 'PngFormat'} + "odata_type": {"#Microsoft.Media.JpgFormat": "JpgFormat", "#Microsoft.Media.PngFormat": "PngFormat"} } - def __init__( - self, - *, - filename_pattern: str, - **kwargs - ): + def __init__(self, *, filename_pattern: str, **kwargs): """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str """ - super(ImageFormat, self).__init__(filename_pattern=filename_pattern, **kwargs) - self.odata_type = '#Microsoft.Media.ImageFormat' # type: str + super().__init__(filename_pattern=filename_pattern, **kwargs) + self.odata_type = "#Microsoft.Media.ImageFormat" # type: str class InputFile(InputDefinition): @@ -5341,7 +5375,7 @@ class InputFile(InputDefinition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar included_tracks: The list of TrackDescriptors which define the metadata and selection of tracks in the input. @@ -5351,13 +5385,13 @@ class InputFile(InputDefinition): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'included_tracks': {'key': 'includedTracks', 'type': '[TrackDescriptor]'}, - 'filename': {'key': 'filename', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "included_tracks": {"key": "includedTracks", "type": "[TrackDescriptor]"}, + "filename": {"key": "filename", "type": "str"}, } def __init__( @@ -5374,12 +5408,12 @@ def __init__( :keyword filename: Name of the file that this input definition applies to. :paramtype filename: str """ - super(InputFile, self).__init__(included_tracks=included_tracks, **kwargs) - self.odata_type = '#Microsoft.Media.InputFile' # type: str + super().__init__(included_tracks=included_tracks, **kwargs) + self.odata_type = "#Microsoft.Media.InputFile" # type: str self.filename = filename -class IPAccessControl(msrest.serialization.Model): +class IPAccessControl(_serialization.Model): """The IP access control. :ivar allow: The IP allow list. @@ -5387,24 +5421,19 @@ class IPAccessControl(msrest.serialization.Model): """ _attribute_map = { - 'allow': {'key': 'allow', 'type': '[IPRange]'}, + "allow": {"key": "allow", "type": "[IPRange]"}, } - def __init__( - self, - *, - allow: Optional[List["_models.IPRange"]] = None, - **kwargs - ): + def __init__(self, *, allow: Optional[List["_models.IPRange"]] = None, **kwargs): """ :keyword allow: The IP allow list. :paramtype allow: list[~azure.mgmt.media.models.IPRange] """ - super(IPAccessControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow = allow -class IPRange(msrest.serialization.Model): +class IPRange(_serialization.Model): """The IP address range in the CIDR scheme. :ivar name: The friendly name for the IP address range. @@ -5416,9 +5445,9 @@ class IPRange(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'address': {'key': 'address', 'type': 'str'}, - 'subnet_prefix_length': {'key': 'subnetPrefixLength', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "address": {"key": "address", "type": "str"}, + "subnet_prefix_length": {"key": "subnetPrefixLength", "type": "int"}, } def __init__( @@ -5437,13 +5466,13 @@ def __init__( :keyword subnet_prefix_length: The subnet mask prefix length (see CIDR notation). :paramtype subnet_prefix_length: int """ - super(IPRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.address = address self.subnet_prefix_length = subnet_prefix_length -class Job(ProxyResource): +class Job(ProxyResource): # pylint: disable=too-many-instance-attributes """A Job resource type. The progress and state can be obtained by polling a Job or subscribing to events using EventGrid. Variables are only populated by the server, and will be ignored when sending a request. @@ -5462,7 +5491,7 @@ class Job(ProxyResource): 'YYYY-MM-DDThh:mm:ssZ' format. :vartype created: ~datetime.datetime :ivar state: The current state of the job. Known values are: "Canceled", "Canceling", "Error", - "Finished", "Processing", "Queued", "Scheduled". + "Finished", "Processing", "Queued", and "Scheduled". :vartype state: str or ~azure.mgmt.media.models.JobState :ivar description: Optional customer supplied description of the Job. :vartype description: str @@ -5475,7 +5504,7 @@ class Job(ProxyResource): :vartype outputs: list[~azure.mgmt.media.models.JobOutput] :ivar priority: Priority with which the job should be processed. Higher priority jobs are processed before lower priority jobs. If not set, the default is normal. Known values are: - "Low", "Normal", "High". + "Low", "Normal", and "High". :vartype priority: str or ~azure.mgmt.media.models.Priority :ivar correlation_data: Customer provided key, value pairs that will be returned in Job and JobOutput state events. @@ -5487,32 +5516,32 @@ class Job(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created': {'readonly': True}, - 'state': {'readonly': True}, - 'last_modified': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created": {"readonly": True}, + "state": {"readonly": True}, + "last_modified": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"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'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'input': {'key': 'properties.input', 'type': 'JobInput'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, - 'outputs': {'key': 'properties.outputs', 'type': '[JobOutput]'}, - 'priority': {'key': 'properties.priority', 'type': 'str'}, - 'correlation_data': {'key': 'properties.correlationData', 'type': '{str}'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "state": {"key": "properties.state", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "input": {"key": "properties.input", "type": "JobInput"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "outputs": {"key": "properties.outputs", "type": "[JobOutput]"}, + "priority": {"key": "properties.priority", "type": "str"}, + "correlation_data": {"key": "properties.correlationData", "type": "{str}"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "end_time": {"key": "properties.endTime", "type": "iso-8601"}, } def __init__( @@ -5534,13 +5563,13 @@ def __init__( :paramtype outputs: list[~azure.mgmt.media.models.JobOutput] :keyword priority: Priority with which the job should be processed. Higher priority jobs are processed before lower priority jobs. If not set, the default is normal. Known values are: - "Low", "Normal", "High". + "Low", "Normal", and "High". :paramtype priority: str or ~azure.mgmt.media.models.Priority :keyword correlation_data: Customer provided key, value pairs that will be returned in Job and JobOutput state events. :paramtype correlation_data: dict[str, str] """ - super(Job, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.created = None self.state = None @@ -5554,7 +5583,7 @@ def __init__( self.end_time = None -class JobCollection(msrest.serialization.Model): +class JobCollection(_serialization.Model): """A collection of Job items. :ivar value: A collection of Job items. @@ -5565,17 +5594,11 @@ class JobCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Job]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Job]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Job"]] = None, - odata_next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Job"]] = None, odata_next_link: Optional[str] = None, **kwargs): """ :keyword value: A collection of Job items. :paramtype value: list[~azure.mgmt.media.models.Job] @@ -5583,12 +5606,12 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(JobCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class JobError(msrest.serialization.Model): +class JobError(_serialization.Model): """Details of JobOutput errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -5596,43 +5619,39 @@ class JobError(msrest.serialization.Model): :ivar code: Error code describing the error. Known values are: "ServiceError", "ServiceTransientError", "DownloadNotAccessible", "DownloadTransientError", "UploadNotAccessible", "UploadTransientError", "ConfigurationUnsupported", "ContentMalformed", - "ContentUnsupported". + and "ContentUnsupported". :vartype code: str or ~azure.mgmt.media.models.JobErrorCode :ivar message: A human-readable language-dependent representation of the error. :vartype message: str :ivar category: Helps with categorization of errors. Known values are: "Service", "Download", - "Upload", "Configuration", "Content". + "Upload", "Configuration", and "Content". :vartype category: str or ~azure.mgmt.media.models.JobErrorCategory :ivar retry: Indicates that it may be possible to retry the Job. If retry is unsuccessful, - please contact Azure support via Azure Portal. Known values are: "DoNotRetry", "MayRetry". + please contact Azure support via Azure Portal. Known values are: "DoNotRetry" and "MayRetry". :vartype retry: str or ~azure.mgmt.media.models.JobRetry :ivar details: An array of details about specific errors that led to this reported error. :vartype details: list[~azure.mgmt.media.models.JobErrorDetail] """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'category': {'readonly': True}, - 'retry': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "category": {"readonly": True}, + "retry": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'retry': {'key': 'retry', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[JobErrorDetail]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "retry": {"key": "retry", "type": "str"}, + "details": {"key": "details", "type": "[JobErrorDetail]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(JobError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.category = None @@ -5640,7 +5659,7 @@ def __init__( self.details = None -class JobErrorDetail(msrest.serialization.Model): +class JobErrorDetail(_serialization.Model): """Details of JobOutput errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -5652,69 +5671,65 @@ class JobErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(JobErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None -class JobInput(msrest.serialization.Model): +class JobInput(_serialization.Model): """Base class for inputs to a Job. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JobInputClip, JobInputSequence, JobInputs. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JobInputClip, JobInputSequence, JobInputs All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.JobInputClip': 'JobInputClip', '#Microsoft.Media.JobInputSequence': 'JobInputSequence', '#Microsoft.Media.JobInputs': 'JobInputs'} + "odata_type": { + "#Microsoft.Media.JobInputClip": "JobInputClip", + "#Microsoft.Media.JobInputSequence": "JobInputSequence", + "#Microsoft.Media.JobInputs": "JobInputs", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(JobInput, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] class JobInputClip(JobInput): """Represents input files for a Job. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JobInputAsset, JobInputHttp. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JobInputAsset, JobInputHttp All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar files: List of files. Required for JobInputHttp. Maximum of 4000 characters each. Query strings will not be returned in service responses to prevent sensitive data exposure. @@ -5737,20 +5752,23 @@ class JobInputClip(JobInput): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'files': {'key': 'files', 'type': '[str]'}, - 'start': {'key': 'start', 'type': 'ClipTime'}, - 'end': {'key': 'end', 'type': 'ClipTime'}, - 'label': {'key': 'label', 'type': 'str'}, - 'input_definitions': {'key': 'inputDefinitions', 'type': '[InputDefinition]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "files": {"key": "files", "type": "[str]"}, + "start": {"key": "start", "type": "ClipTime"}, + "end": {"key": "end", "type": "ClipTime"}, + "label": {"key": "label", "type": "str"}, + "input_definitions": {"key": "inputDefinitions", "type": "[InputDefinition]"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.JobInputAsset': 'JobInputAsset', '#Microsoft.Media.JobInputHttp': 'JobInputHttp'} + "odata_type": { + "#Microsoft.Media.JobInputAsset": "JobInputAsset", + "#Microsoft.Media.JobInputHttp": "JobInputHttp", + } } def __init__( @@ -5783,8 +5801,8 @@ def __init__( defines a list of track selections and related metadata. :paramtype input_definitions: list[~azure.mgmt.media.models.InputDefinition] """ - super(JobInputClip, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.JobInputClip' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.JobInputClip" # type: str self.files = files self.start = start self.end = end @@ -5797,7 +5815,7 @@ class JobInputAsset(JobInputClip): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar files: List of files. Required for JobInputHttp. Maximum of 4000 characters each. Query strings will not be returned in service responses to prevent sensitive data exposure. @@ -5817,23 +5835,23 @@ class JobInputAsset(JobInputClip): :ivar input_definitions: Defines a list of InputDefinitions. For each InputDefinition, it defines a list of track selections and related metadata. :vartype input_definitions: list[~azure.mgmt.media.models.InputDefinition] - :ivar asset_name: Required. The name of the input Asset. + :ivar asset_name: The name of the input Asset. Required. :vartype asset_name: str """ _validation = { - 'odata_type': {'required': True}, - 'asset_name': {'required': True}, + "odata_type": {"required": True}, + "asset_name": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'files': {'key': 'files', 'type': '[str]'}, - 'start': {'key': 'start', 'type': 'ClipTime'}, - 'end': {'key': 'end', 'type': 'ClipTime'}, - 'label': {'key': 'label', 'type': 'str'}, - 'input_definitions': {'key': 'inputDefinitions', 'type': '[InputDefinition]'}, - 'asset_name': {'key': 'assetName', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "files": {"key": "files", "type": "[str]"}, + "start": {"key": "start", "type": "ClipTime"}, + "end": {"key": "end", "type": "ClipTime"}, + "label": {"key": "label", "type": "str"}, + "input_definitions": {"key": "inputDefinitions", "type": "[InputDefinition]"}, + "asset_name": {"key": "assetName", "type": "str"}, } def __init__( @@ -5866,11 +5884,11 @@ def __init__( :keyword input_definitions: Defines a list of InputDefinitions. For each InputDefinition, it defines a list of track selections and related metadata. :paramtype input_definitions: list[~azure.mgmt.media.models.InputDefinition] - :keyword asset_name: Required. The name of the input Asset. + :keyword asset_name: The name of the input Asset. Required. :paramtype asset_name: str """ - super(JobInputAsset, self).__init__(files=files, start=start, end=end, label=label, input_definitions=input_definitions, **kwargs) - self.odata_type = '#Microsoft.Media.JobInputAsset' # type: str + super().__init__(files=files, start=start, end=end, label=label, input_definitions=input_definitions, **kwargs) + self.odata_type = "#Microsoft.Media.JobInputAsset" # type: str self.asset_name = asset_name @@ -5879,7 +5897,7 @@ class JobInputHttp(JobInputClip): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar files: List of files. Required for JobInputHttp. Maximum of 4000 characters each. Query strings will not be returned in service responses to prevent sensitive data exposure. @@ -5907,17 +5925,17 @@ class JobInputHttp(JobInputClip): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'files': {'key': 'files', 'type': '[str]'}, - 'start': {'key': 'start', 'type': 'ClipTime'}, - 'end': {'key': 'end', 'type': 'ClipTime'}, - 'label': {'key': 'label', 'type': 'str'}, - 'input_definitions': {'key': 'inputDefinitions', 'type': '[InputDefinition]'}, - 'base_uri': {'key': 'baseUri', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "files": {"key": "files", "type": "[str]"}, + "start": {"key": "start", "type": "ClipTime"}, + "end": {"key": "end", "type": "ClipTime"}, + "label": {"key": "label", "type": "str"}, + "input_definitions": {"key": "inputDefinitions", "type": "[InputDefinition]"}, + "base_uri": {"key": "baseUri", "type": "str"}, } def __init__( @@ -5956,8 +5974,8 @@ def __init__( responses to prevent sensitive data exposure. :paramtype base_uri: str """ - super(JobInputHttp, self).__init__(files=files, start=start, end=end, label=label, input_definitions=input_definitions, **kwargs) - self.odata_type = '#Microsoft.Media.JobInputHttp' # type: str + super().__init__(files=files, start=start, end=end, label=label, input_definitions=input_definitions, **kwargs) + self.odata_type = "#Microsoft.Media.JobInputHttp" # type: str self.base_uri = base_uri @@ -5966,33 +5984,28 @@ class JobInputs(JobInput): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar inputs: List of inputs to a Job. :vartype inputs: list[~azure.mgmt.media.models.JobInput] """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'inputs': {'key': 'inputs', 'type': '[JobInput]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "inputs": {"key": "inputs", "type": "[JobInput]"}, } - def __init__( - self, - *, - inputs: Optional[List["_models.JobInput"]] = None, - **kwargs - ): + def __init__(self, *, inputs: Optional[List["_models.JobInput"]] = None, **kwargs): """ :keyword inputs: List of inputs to a Job. :paramtype inputs: list[~azure.mgmt.media.models.JobInput] """ - super(JobInputs, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.JobInputs' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.JobInputs" # type: str self.inputs = inputs @@ -6001,47 +6014,42 @@ class JobInputSequence(JobInput): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar inputs: JobInputs that make up the timeline. :vartype inputs: list[~azure.mgmt.media.models.JobInputClip] """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'inputs': {'key': 'inputs', 'type': '[JobInputClip]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "inputs": {"key": "inputs", "type": "[JobInputClip]"}, } - def __init__( - self, - *, - inputs: Optional[List["_models.JobInputClip"]] = None, - **kwargs - ): + def __init__(self, *, inputs: Optional[List["_models.JobInputClip"]] = None, **kwargs): """ :keyword inputs: JobInputs that make up the timeline. :paramtype inputs: list[~azure.mgmt.media.models.JobInputClip] """ - super(JobInputSequence, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.JobInputSequence' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.JobInputSequence" # type: str self.inputs = inputs -class JobOutput(msrest.serialization.Model): +class JobOutput(_serialization.Model): """Describes all the properties of a JobOutput. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JobOutputAsset. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JobOutputAsset Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar error: If the JobOutput is in the Error state, it contains the details of the error. :vartype error: ~azure.mgmt.media.models.JobError @@ -6049,7 +6057,7 @@ class JobOutput(msrest.serialization.Model): output. :vartype preset_override: ~azure.mgmt.media.models.Preset :ivar state: Describes the state of the JobOutput. Known values are: "Canceled", "Canceling", - "Error", "Finished", "Processing", "Queued", "Scheduled". + "Error", "Finished", "Processing", "Queued", and "Scheduled". :vartype state: str or ~azure.mgmt.media.models.JobState :ivar progress: If the JobOutput is in a Processing state, this contains the Job completion percentage. The value is an estimate and not intended to be used to predict Job completion @@ -6073,36 +6081,28 @@ class JobOutput(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, - 'error': {'readonly': True}, - 'state': {'readonly': True}, - 'progress': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, + "odata_type": {"required": True}, + "error": {"readonly": True}, + "state": {"readonly": True}, + "progress": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'JobError'}, - 'preset_override': {'key': 'presetOverride', 'type': 'Preset'}, - 'state': {'key': 'state', 'type': 'str'}, - 'progress': {'key': 'progress', 'type': 'int'}, - 'label': {'key': 'label', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - } - - _subtype_map = { - 'odata_type': {'#Microsoft.Media.JobOutputAsset': 'JobOutputAsset'} - } - - def __init__( - self, - *, - preset_override: Optional["_models.Preset"] = None, - label: Optional[str] = None, - **kwargs - ): + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "error": {"key": "error", "type": "JobError"}, + "preset_override": {"key": "presetOverride", "type": "Preset"}, + "state": {"key": "state", "type": "str"}, + "progress": {"key": "progress", "type": "int"}, + "label": {"key": "label", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + } + + _subtype_map = {"odata_type": {"#Microsoft.Media.JobOutputAsset": "JobOutputAsset"}} + + def __init__(self, *, preset_override: Optional["_models.Preset"] = None, label: Optional[str] = None, **kwargs): """ :keyword preset_override: A preset used to override the preset in the corresponding transform output. @@ -6119,7 +6119,7 @@ def __init__( corresponding TransformOutput within its Transform. :paramtype label: str """ - super(JobOutput, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.error = None self.preset_override = preset_override @@ -6137,7 +6137,7 @@ class JobOutputAsset(JobOutput): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar error: If the JobOutput is in the Error state, it contains the details of the error. :vartype error: ~azure.mgmt.media.models.JobError @@ -6145,7 +6145,7 @@ class JobOutputAsset(JobOutput): output. :vartype preset_override: ~azure.mgmt.media.models.Preset :ivar state: Describes the state of the JobOutput. Known values are: "Canceled", "Canceling", - "Error", "Finished", "Processing", "Queued", "Scheduled". + "Error", "Finished", "Processing", "Queued", and "Scheduled". :vartype state: str or ~azure.mgmt.media.models.JobState :ivar progress: If the JobOutput is in a Processing state, this contains the Job completion percentage. The value is an estimate and not intended to be used to predict Job completion @@ -6166,30 +6166,30 @@ class JobOutputAsset(JobOutput): :vartype start_time: ~datetime.datetime :ivar end_time: The UTC date and time at which this Job Output finished processing. :vartype end_time: ~datetime.datetime - :ivar asset_name: Required. The name of the output Asset. + :ivar asset_name: The name of the output Asset. Required. :vartype asset_name: str """ _validation = { - 'odata_type': {'required': True}, - 'error': {'readonly': True}, - 'state': {'readonly': True}, - 'progress': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'asset_name': {'required': True}, + "odata_type": {"required": True}, + "error": {"readonly": True}, + "state": {"readonly": True}, + "progress": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "asset_name": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'JobError'}, - 'preset_override': {'key': 'presetOverride', 'type': 'Preset'}, - 'state': {'key': 'state', 'type': 'str'}, - 'progress': {'key': 'progress', 'type': 'int'}, - 'label': {'key': 'label', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'asset_name': {'key': 'assetName', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "error": {"key": "error", "type": "JobError"}, + "preset_override": {"key": "presetOverride", "type": "Preset"}, + "state": {"key": "state", "type": "str"}, + "progress": {"key": "progress", "type": "int"}, + "label": {"key": "label", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "asset_name": {"key": "assetName", "type": "str"}, } def __init__( @@ -6215,11 +6215,11 @@ def __init__( JobOutput within the Job. Note that this index is the same as the relative index of the corresponding TransformOutput within its Transform. :paramtype label: str - :keyword asset_name: Required. The name of the output Asset. + :keyword asset_name: The name of the output Asset. Required. :paramtype asset_name: str """ - super(JobOutputAsset, self).__init__(preset_override=preset_override, label=label, **kwargs) - self.odata_type = '#Microsoft.Media.JobOutputAsset' # type: str + super().__init__(preset_override=preset_override, label=label, **kwargs) + self.odata_type = "#Microsoft.Media.JobOutputAsset" # type: str self.asset_name = asset_name @@ -6228,53 +6228,47 @@ class JpgFormat(ImageFormat): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, } - def __init__( - self, - *, - filename_pattern: str, - **kwargs - ): + def __init__(self, *, filename_pattern: str, **kwargs): """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str """ - super(JpgFormat, self).__init__(filename_pattern=filename_pattern, **kwargs) - self.odata_type = '#Microsoft.Media.JpgFormat' # type: str + super().__init__(filename_pattern=filename_pattern, **kwargs) + self.odata_type = "#Microsoft.Media.JpgFormat" # type: str class JpgImage(Image): @@ -6282,7 +6276,7 @@ class JpgImage(Image): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -6292,17 +6286,18 @@ class JpgImage(Image): value will follow the input source setting. :vartype key_frame_interval: ~datetime.timedelta :ivar stretch_mode: The resizing mode - how the input video will be resized to fit the desired - output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", "AutoFit". + output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :vartype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode - :ivar start: Required. The position in the input video from where to start generating - thumbnails. The value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or - a frame count (For example, 10 to start at the 10th frame), or a relative value to stream - duration (For example, 10% to start at 10% of stream duration). Also supports a macro {Best}, - which tells the encoder to select the best thumbnail from the first few seconds of the video - and will only produce one thumbnail, no matter what other settings are for Step and Range. The - default value is macro {Best}. + :ivar start: The position in the input video from where to start generating thumbnails. The + value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or a frame count + (For example, 10 to start at the 10th frame), or a relative value to stream duration (For + example, 10% to start at 10% of stream duration). Also supports a macro {Best}, which tells the + encoder to select the best thumbnail from the first few seconds of the video and will only + produce one thumbnail, no matter what other settings are for Step and Range. The default value + is macro {Best}. Required. :vartype start: str :ivar step: The intervals at which thumbnails are generated. The value can be in ISO 8601 format (For example, PT05S for one image every 5 seconds), or a frame count (For example, 30 @@ -6334,21 +6329,21 @@ class JpgImage(Image): """ _validation = { - 'odata_type': {'required': True}, - 'start': {'required': True}, + "odata_type": {"required": True}, + "start": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'str'}, - 'step': {'key': 'step', 'type': 'str'}, - 'range': {'key': 'range', 'type': 'str'}, - 'layers': {'key': 'layers', 'type': '[JpgLayer]'}, - 'sprite_column': {'key': 'spriteColumn', 'type': 'int'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "sync_mode": {"key": "syncMode", "type": "str"}, + "start": {"key": "start", "type": "str"}, + "step": {"key": "step", "type": "str"}, + "range": {"key": "range", "type": "str"}, + "layers": {"key": "layers", "type": "[JpgLayer]"}, + "sprite_column": {"key": "spriteColumn", "type": "int"}, } def __init__( @@ -6375,18 +6370,19 @@ def __init__( KeyFrameInterval value will follow the input source setting. :paramtype key_frame_interval: ~datetime.timedelta :keyword stretch_mode: The resizing mode - how the input video will be resized to fit the - desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", + desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :paramtype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode - :keyword start: Required. The position in the input video from where to start generating - thumbnails. The value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or - a frame count (For example, 10 to start at the 10th frame), or a relative value to stream - duration (For example, 10% to start at 10% of stream duration). Also supports a macro {Best}, - which tells the encoder to select the best thumbnail from the first few seconds of the video - and will only produce one thumbnail, no matter what other settings are for Step and Range. The - default value is macro {Best}. + :keyword start: The position in the input video from where to start generating thumbnails. The + value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or a frame count + (For example, 10 to start at the 10th frame), or a relative value to stream duration (For + example, 10% to start at 10% of stream duration). Also supports a macro {Best}, which tells the + encoder to select the best thumbnail from the first few seconds of the video and will only + produce one thumbnail, no matter what other settings are for Step and Range. The default value + is macro {Best}. Required. :paramtype start: str :keyword step: The intervals at which thumbnails are generated. The value can be in ISO 8601 format (For example, PT05S for one image every 5 seconds), or a frame count (For example, 30 @@ -6416,8 +6412,17 @@ def __init__( resolution limit 65535x65535. :paramtype sprite_column: int """ - super(JpgImage, self).__init__(label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, start=start, step=step, range=range, **kwargs) - self.odata_type = '#Microsoft.Media.JpgImage' # type: str + super().__init__( + label=label, + key_frame_interval=key_frame_interval, + stretch_mode=stretch_mode, + sync_mode=sync_mode, + start=start, + step=step, + range=range, + **kwargs + ) + self.odata_type = "#Microsoft.Media.JpgImage" # type: str self.layers = layers self.sprite_column = sprite_column @@ -6442,10 +6447,10 @@ class JpgLayer(Layer): """ _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'quality': {'key': 'quality', 'type': 'int'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "quality": {"key": "quality", "type": "int"}, } def __init__( @@ -6473,11 +6478,11 @@ def __init__( default is 70. :paramtype quality: int """ - super(JpgLayer, self).__init__(width=width, height=height, label=label, **kwargs) + super().__init__(width=width, height=height, label=label, **kwargs) self.quality = quality -class KeyDelivery(msrest.serialization.Model): +class KeyDelivery(_serialization.Model): """KeyDelivery. :ivar access_control: The access control properties for Key Delivery. @@ -6485,24 +6490,19 @@ class KeyDelivery(msrest.serialization.Model): """ _attribute_map = { - 'access_control': {'key': 'accessControl', 'type': 'AccessControl'}, + "access_control": {"key": "accessControl", "type": "AccessControl"}, } - def __init__( - self, - *, - access_control: Optional["_models.AccessControl"] = None, - **kwargs - ): + def __init__(self, *, access_control: Optional["_models.AccessControl"] = None, **kwargs): """ :keyword access_control: The access control properties for Key Delivery. :paramtype access_control: ~azure.mgmt.media.models.AccessControl """ - super(KeyDelivery, self).__init__(**kwargs) + super().__init__(**kwargs) self.access_control = access_control -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """KeyVaultProperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -6517,36 +6517,31 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_key_identifier': {'readonly': True}, + "current_key_identifier": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'current_key_identifier': {'key': 'currentKeyIdentifier', 'type': 'str'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "current_key_identifier": {"key": "currentKeyIdentifier", "type": "str"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, **kwargs): """ :keyword key_identifier: The URL of the Key Vault key used to encrypt the account. The key may either be versioned (for example https://vault/keys/mykey/version1) or reference a key without a version (for example https://vault/keys/mykey). :paramtype key_identifier: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.current_key_identifier = None -class ListContainerSasInput(msrest.serialization.Model): +class ListContainerSasInput(_serialization.Model): """The parameters to the list SAS request. :ivar permissions: The permissions to set on the SAS URL. Known values are: "Read", - "ReadWrite", "ReadWriteDelete". + "ReadWrite", and "ReadWriteDelete". :vartype permissions: str or ~azure.mgmt.media.models.AssetContainerPermission :ivar expiry_time: The SAS URL expiration time. This must be less than 24 hours from the current time. @@ -6554,8 +6549,8 @@ class ListContainerSasInput(msrest.serialization.Model): """ _attribute_map = { - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, + "permissions": {"key": "permissions", "type": "str"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, } def __init__( @@ -6567,18 +6562,18 @@ def __init__( ): """ :keyword permissions: The permissions to set on the SAS URL. Known values are: "Read", - "ReadWrite", "ReadWriteDelete". + "ReadWrite", and "ReadWriteDelete". :paramtype permissions: str or ~azure.mgmt.media.models.AssetContainerPermission :keyword expiry_time: The SAS URL expiration time. This must be less than 24 hours from the current time. :paramtype expiry_time: ~datetime.datetime """ - super(ListContainerSasInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.permissions = permissions self.expiry_time = expiry_time -class ListContentKeysResponse(msrest.serialization.Model): +class ListContentKeysResponse(_serialization.Model): """Class of response for listContentKeys action. :ivar content_keys: ContentKeys used by current Streaming Locator. @@ -6586,24 +6581,19 @@ class ListContentKeysResponse(msrest.serialization.Model): """ _attribute_map = { - 'content_keys': {'key': 'contentKeys', 'type': '[StreamingLocatorContentKey]'}, + "content_keys": {"key": "contentKeys", "type": "[StreamingLocatorContentKey]"}, } - def __init__( - self, - *, - content_keys: Optional[List["_models.StreamingLocatorContentKey"]] = None, - **kwargs - ): + def __init__(self, *, content_keys: Optional[List["_models.StreamingLocatorContentKey"]] = None, **kwargs): """ :keyword content_keys: ContentKeys used by current Streaming Locator. :paramtype content_keys: list[~azure.mgmt.media.models.StreamingLocatorContentKey] """ - super(ListContentKeysResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.content_keys = content_keys -class ListEdgePoliciesInput(msrest.serialization.Model): +class ListEdgePoliciesInput(_serialization.Model): """ListEdgePoliciesInput. :ivar device_id: Unique identifier of the edge device. @@ -6611,24 +6601,19 @@ class ListEdgePoliciesInput(msrest.serialization.Model): """ _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, + "device_id": {"key": "deviceId", "type": "str"}, } - def __init__( - self, - *, - device_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, device_id: Optional[str] = None, **kwargs): """ :keyword device_id: Unique identifier of the edge device. :paramtype device_id: str """ - super(ListEdgePoliciesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.device_id = device_id -class ListPathsResponse(msrest.serialization.Model): +class ListPathsResponse(_serialization.Model): """Class of response for listPaths action. :ivar streaming_paths: Streaming Paths supported by current Streaming Locator. @@ -6638,8 +6623,8 @@ class ListPathsResponse(msrest.serialization.Model): """ _attribute_map = { - 'streaming_paths': {'key': 'streamingPaths', 'type': '[StreamingPath]'}, - 'download_paths': {'key': 'downloadPaths', 'type': '[str]'}, + "streaming_paths": {"key": "streamingPaths", "type": "[StreamingPath]"}, + "download_paths": {"key": "downloadPaths", "type": "[str]"}, } def __init__( @@ -6655,12 +6640,12 @@ def __init__( :keyword download_paths: Download Paths supported by current Streaming Locator. :paramtype download_paths: list[str] """ - super(ListPathsResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.streaming_paths = streaming_paths self.download_paths = download_paths -class ListStreamingLocatorsResponse(msrest.serialization.Model): +class ListStreamingLocatorsResponse(_serialization.Model): """The Streaming Locators associated with this Asset. Variables are only populated by the server, and will be ignored when sending a request. @@ -6670,20 +6655,16 @@ class ListStreamingLocatorsResponse(msrest.serialization.Model): """ _validation = { - 'streaming_locators': {'readonly': True}, + "streaming_locators": {"readonly": True}, } _attribute_map = { - 'streaming_locators': {'key': 'streamingLocators', 'type': '[AssetStreamingLocator]'}, + "streaming_locators": {"key": "streamingLocators", "type": "[AssetStreamingLocator]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListStreamingLocatorsResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.streaming_locators = None @@ -6702,46 +6683,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class LiveEvent(TrackedResource): +class LiveEvent(TrackedResource): # pylint: disable=too-many-instance-attributes """The live event. Variables are only populated by the server, and will be ignored when sending a request. @@ -6756,9 +6731,9 @@ class LiveEvent(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.media.models.SystemData @@ -6781,7 +6756,7 @@ class LiveEvent(TrackedResource): :vartype provisioning_state: str :ivar resource_state: The resource state of the live event. See https://go.microsoft.com/fwlink/?linkid=2139012 for more information. Known values are: - "Stopped", "Allocating", "StandBy", "Starting", "Running", "Stopping", "Deleting". + "Stopped", "Allocating", "StandBy", "Starting", "Running", "Stopping", and "Deleting". :vartype resource_state: str or ~azure.mgmt.media.models.LiveEventResourceState :ivar cross_site_access_policies: Live event cross site access policies. :vartype cross_site_access_policies: ~azure.mgmt.media.models.CrossSiteAccessPolicies @@ -6805,37 +6780,37 @@ class LiveEvent(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'resource_state': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'input': {'key': 'properties.input', 'type': 'LiveEventInput'}, - 'preview': {'key': 'properties.preview', 'type': 'LiveEventPreview'}, - 'encoding': {'key': 'properties.encoding', 'type': 'LiveEventEncoding'}, - 'transcriptions': {'key': 'properties.transcriptions', 'type': '[LiveEventTranscription]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'resource_state': {'key': 'properties.resourceState', 'type': 'str'}, - 'cross_site_access_policies': {'key': 'properties.crossSiteAccessPolicies', 'type': 'CrossSiteAccessPolicies'}, - 'use_static_hostname': {'key': 'properties.useStaticHostname', 'type': 'bool'}, - 'hostname_prefix': {'key': 'properties.hostnamePrefix', 'type': 'str'}, - 'stream_options': {'key': 'properties.streamOptions', 'type': '[str]'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "resource_state": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "input": {"key": "properties.input", "type": "LiveEventInput"}, + "preview": {"key": "properties.preview", "type": "LiveEventPreview"}, + "encoding": {"key": "properties.encoding", "type": "LiveEventEncoding"}, + "transcriptions": {"key": "properties.transcriptions", "type": "[LiveEventTranscription]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "resource_state": {"key": "properties.resourceState", "type": "str"}, + "cross_site_access_policies": {"key": "properties.crossSiteAccessPolicies", "type": "CrossSiteAccessPolicies"}, + "use_static_hostname": {"key": "properties.useStaticHostname", "type": "bool"}, + "hostname_prefix": {"key": "properties.hostnamePrefix", "type": "str"}, + "stream_options": {"key": "properties.streamOptions", "type": "[str]"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, } def __init__( @@ -6855,9 +6830,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword description: A description for the live event. :paramtype description: str @@ -6890,7 +6865,7 @@ def __init__( and 'LowLatency'. :paramtype stream_options: list[str or ~azure.mgmt.media.models.StreamOptionsFlag] """ - super(LiveEvent, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.system_data = None self.description = description self.input = input @@ -6907,7 +6882,7 @@ def __init__( self.last_modified = None -class LiveEventActionInput(msrest.serialization.Model): +class LiveEventActionInput(_serialization.Model): """The LiveEvent action input parameter definition. :ivar remove_outputs_on_stop: The flag indicates whether live outputs are automatically deleted @@ -6916,26 +6891,21 @@ class LiveEventActionInput(msrest.serialization.Model): """ _attribute_map = { - 'remove_outputs_on_stop': {'key': 'removeOutputsOnStop', 'type': 'bool'}, + "remove_outputs_on_stop": {"key": "removeOutputsOnStop", "type": "bool"}, } - def __init__( - self, - *, - remove_outputs_on_stop: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, remove_outputs_on_stop: Optional[bool] = None, **kwargs): """ :keyword remove_outputs_on_stop: The flag indicates whether live outputs are automatically deleted when live event is being stopped. Deleting live outputs do not delete the underlying assets. :paramtype remove_outputs_on_stop: bool """ - super(LiveEventActionInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.remove_outputs_on_stop = remove_outputs_on_stop -class LiveEventEncoding(msrest.serialization.Model): +class LiveEventEncoding(_serialization.Model): """Specifies the live event type and optional encoding settings for encoding live events. :ivar encoding_type: Live event type. When encodingType is set to PassthroughBasic or @@ -6944,7 +6914,7 @@ class LiveEventEncoding(msrest.serialization.Model): incoming stream into multiple bitrates or layers. See https://go.microsoft.com/fwlink/?linkid=2095101 for more information. This property cannot be modified after the live event is created. Known values are: "None", "Standard", "Premium1080p", - "PassthroughBasic", "PassthroughStandard". + "PassthroughBasic", and "PassthroughStandard". :vartype encoding_type: str or ~azure.mgmt.media.models.LiveEventEncodingType :ivar preset_name: The optional encoding preset name, used when encodingType is not None. This value is specified at creation time and cannot be updated. If the encodingType is set to @@ -6952,7 +6922,7 @@ class LiveEventEncoding(msrest.serialization.Model): Premium1080p, the default preset is ‘Default1080p’. :vartype preset_name: str :ivar stretch_mode: Specifies how the input video will be resized to fit the desired output - resolution(s). Default is None. Known values are: "None", "AutoSize", "AutoFit". + resolution(s). Default is None. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode :ivar key_frame_interval: Use an ISO 8601 time value between 0.5 to 20 seconds to specify the output fragment length for the video and audio tracks of an encoding live event. For example, @@ -6964,10 +6934,10 @@ class LiveEventEncoding(msrest.serialization.Model): """ _attribute_map = { - 'encoding_type': {'key': 'encodingType', 'type': 'str'}, - 'preset_name': {'key': 'presetName', 'type': 'str'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, + "encoding_type": {"key": "encodingType", "type": "str"}, + "preset_name": {"key": "presetName", "type": "str"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, } def __init__( @@ -6986,7 +6956,7 @@ def __init__( incoming stream into multiple bitrates or layers. See https://go.microsoft.com/fwlink/?linkid=2095101 for more information. This property cannot be modified after the live event is created. Known values are: "None", "Standard", "Premium1080p", - "PassthroughBasic", "PassthroughStandard". + "PassthroughBasic", and "PassthroughStandard". :paramtype encoding_type: str or ~azure.mgmt.media.models.LiveEventEncodingType :keyword preset_name: The optional encoding preset name, used when encodingType is not None. This value is specified at creation time and cannot be updated. If the encodingType is set to @@ -6994,7 +6964,7 @@ def __init__( Premium1080p, the default preset is ‘Default1080p’. :paramtype preset_name: str :keyword stretch_mode: Specifies how the input video will be resized to fit the desired output - resolution(s). Default is None. Known values are: "None", "AutoSize", "AutoFit". + resolution(s). Default is None. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode :keyword key_frame_interval: Use an ISO 8601 time value between 0.5 to 20 seconds to specify the output fragment length for the video and audio tracks of an encoding live event. For @@ -7004,14 +6974,14 @@ def __init__( pass-through live events. :paramtype key_frame_interval: ~datetime.timedelta """ - super(LiveEventEncoding, self).__init__(**kwargs) + super().__init__(**kwargs) self.encoding_type = encoding_type self.preset_name = preset_name self.stretch_mode = stretch_mode self.key_frame_interval = key_frame_interval -class LiveEventEndpoint(msrest.serialization.Model): +class LiveEventEndpoint(_serialization.Model): """The live event endpoint. :ivar protocol: The endpoint protocol. @@ -7021,35 +6991,29 @@ class LiveEventEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, + "protocol": {"key": "protocol", "type": "str"}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - protocol: Optional[str] = None, - url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, protocol: Optional[str] = None, url: Optional[str] = None, **kwargs): """ :keyword protocol: The endpoint protocol. :paramtype protocol: str :keyword url: The endpoint URL. :paramtype url: str """ - super(LiveEventEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.protocol = protocol self.url = url -class LiveEventInput(msrest.serialization.Model): +class LiveEventInput(_serialization.Model): """The live event input. All required parameters must be populated in order to send to Azure. - :ivar streaming_protocol: Required. The input protocol for the live event. This is specified at - creation time and cannot be updated. Known values are: "FragmentedMP4", "RTMP". + :ivar streaming_protocol: The input protocol for the live event. This is specified at creation + time and cannot be updated. Required. Known values are: "FragmentedMP4" and "RTMP". :vartype streaming_protocol: str or ~azure.mgmt.media.models.LiveEventInputProtocol :ivar access_control: Access control for live event input. :vartype access_control: ~azure.mgmt.media.models.LiveEventInputAccessControl @@ -7066,15 +7030,15 @@ class LiveEventInput(msrest.serialization.Model): """ _validation = { - 'streaming_protocol': {'required': True}, + "streaming_protocol": {"required": True}, } _attribute_map = { - 'streaming_protocol': {'key': 'streamingProtocol', 'type': 'str'}, - 'access_control': {'key': 'accessControl', 'type': 'LiveEventInputAccessControl'}, - 'key_frame_interval_duration': {'key': 'keyFrameIntervalDuration', 'type': 'str'}, - 'access_token': {'key': 'accessToken', 'type': 'str'}, - 'endpoints': {'key': 'endpoints', 'type': '[LiveEventEndpoint]'}, + "streaming_protocol": {"key": "streamingProtocol", "type": "str"}, + "access_control": {"key": "accessControl", "type": "LiveEventInputAccessControl"}, + "key_frame_interval_duration": {"key": "keyFrameIntervalDuration", "type": "str"}, + "access_token": {"key": "accessToken", "type": "str"}, + "endpoints": {"key": "endpoints", "type": "[LiveEventEndpoint]"}, } def __init__( @@ -7088,8 +7052,8 @@ def __init__( **kwargs ): """ - :keyword streaming_protocol: Required. The input protocol for the live event. This is specified - at creation time and cannot be updated. Known values are: "FragmentedMP4", "RTMP". + :keyword streaming_protocol: The input protocol for the live event. This is specified at + creation time and cannot be updated. Required. Known values are: "FragmentedMP4" and "RTMP". :paramtype streaming_protocol: str or ~azure.mgmt.media.models.LiveEventInputProtocol :keyword access_control: Access control for live event input. :paramtype access_control: ~azure.mgmt.media.models.LiveEventInputAccessControl @@ -7104,7 +7068,7 @@ def __init__( :keyword endpoints: The input endpoints for the live event. :paramtype endpoints: list[~azure.mgmt.media.models.LiveEventEndpoint] """ - super(LiveEventInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.streaming_protocol = streaming_protocol self.access_control = access_control self.key_frame_interval_duration = key_frame_interval_duration @@ -7112,7 +7076,7 @@ def __init__( self.endpoints = endpoints -class LiveEventInputAccessControl(msrest.serialization.Model): +class LiveEventInputAccessControl(_serialization.Model): """The IP access control for live event input. :ivar ip: The IP access control properties. @@ -7120,24 +7084,19 @@ class LiveEventInputAccessControl(msrest.serialization.Model): """ _attribute_map = { - 'ip': {'key': 'ip', 'type': 'IPAccessControl'}, + "ip": {"key": "ip", "type": "IPAccessControl"}, } - def __init__( - self, - *, - ip: Optional["_models.IPAccessControl"] = None, - **kwargs - ): + def __init__(self, *, ip: Optional["_models.IPAccessControl"] = None, **kwargs): """ :keyword ip: The IP access control properties. :paramtype ip: ~azure.mgmt.media.models.IPAccessControl """ - super(LiveEventInputAccessControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip = ip -class LiveEventInputTrackSelection(msrest.serialization.Model): +class LiveEventInputTrackSelection(_serialization.Model): """A track selection condition. This property is reserved for future use, any value set on this property will be ignored. :ivar property: Property name to select. This property is reserved for future use, any value @@ -7152,18 +7111,13 @@ class LiveEventInputTrackSelection(msrest.serialization.Model): """ _attribute_map = { - 'property': {'key': 'property', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "property": {"key": "property", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - property: Optional[str] = None, - operation: Optional[str] = None, - value: Optional[str] = None, - **kwargs + self, *, property: Optional[str] = None, operation: Optional[str] = None, value: Optional[str] = None, **kwargs ): """ :keyword property: Property name to select. This property is reserved for future use, any value @@ -7176,13 +7130,13 @@ def __init__( set on this property will be ignored. :paramtype value: str """ - super(LiveEventInputTrackSelection, self).__init__(**kwargs) + super().__init__(**kwargs) self.property = property self.operation = operation self.value = value -class LiveEventListResult(msrest.serialization.Model): +class LiveEventListResult(_serialization.Model): """The LiveEvent list result. :ivar value: The result of the List Live Event operation. @@ -7195,9 +7149,9 @@ class LiveEventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LiveEvent]'}, - 'odata_count': {'key': '@odata\\.count', 'type': 'int'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[LiveEvent]"}, + "odata_count": {"key": "@odata\\.count", "type": "int"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( @@ -7217,46 +7171,41 @@ def __init__( incomplete list of live outputs. :paramtype odata_next_link: str """ - super(LiveEventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_count = odata_count self.odata_next_link = odata_next_link -class LiveEventOutputTranscriptionTrack(msrest.serialization.Model): +class LiveEventOutputTranscriptionTrack(_serialization.Model): """Describes a transcription track in the output of a live event, generated using speech-to-text transcription. This property is reserved for future use, any value set on this property will be ignored. All required parameters must be populated in order to send to Azure. - :ivar track_name: Required. The output track name. This property is reserved for future use, - any value set on this property will be ignored. + :ivar track_name: The output track name. This property is reserved for future use, any value + set on this property will be ignored. Required. :vartype track_name: str """ _validation = { - 'track_name': {'required': True}, + "track_name": {"required": True}, } _attribute_map = { - 'track_name': {'key': 'trackName', 'type': 'str'}, + "track_name": {"key": "trackName", "type": "str"}, } - def __init__( - self, - *, - track_name: str, - **kwargs - ): + def __init__(self, *, track_name: str, **kwargs): """ - :keyword track_name: Required. The output track name. This property is reserved for future use, - any value set on this property will be ignored. + :keyword track_name: The output track name. This property is reserved for future use, any value + set on this property will be ignored. Required. :paramtype track_name: str """ - super(LiveEventOutputTranscriptionTrack, self).__init__(**kwargs) + super().__init__(**kwargs) self.track_name = track_name -class LiveEventPreview(msrest.serialization.Model): +class LiveEventPreview(_serialization.Model): """Live event preview settings. :ivar endpoints: The endpoints for preview. Do not share the preview URL with the live event @@ -7281,11 +7230,11 @@ class LiveEventPreview(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': '[LiveEventEndpoint]'}, - 'access_control': {'key': 'accessControl', 'type': 'LiveEventPreviewAccessControl'}, - 'preview_locator': {'key': 'previewLocator', 'type': 'str'}, - 'streaming_policy_name': {'key': 'streamingPolicyName', 'type': 'str'}, - 'alternative_media_id': {'key': 'alternativeMediaId', 'type': 'str'}, + "endpoints": {"key": "endpoints", "type": "[LiveEventEndpoint]"}, + "access_control": {"key": "accessControl", "type": "LiveEventPreviewAccessControl"}, + "preview_locator": {"key": "previewLocator", "type": "str"}, + "streaming_policy_name": {"key": "streamingPolicyName", "type": "str"}, + "alternative_media_id": {"key": "alternativeMediaId", "type": "str"}, } def __init__( @@ -7319,7 +7268,7 @@ def __init__( field. :paramtype alternative_media_id: str """ - super(LiveEventPreview, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.access_control = access_control self.preview_locator = preview_locator @@ -7327,7 +7276,7 @@ def __init__( self.alternative_media_id = alternative_media_id -class LiveEventPreviewAccessControl(msrest.serialization.Model): +class LiveEventPreviewAccessControl(_serialization.Model): """The IP access control for the live event preview endpoint. :ivar ip: The IP access control properties. @@ -7335,24 +7284,19 @@ class LiveEventPreviewAccessControl(msrest.serialization.Model): """ _attribute_map = { - 'ip': {'key': 'ip', 'type': 'IPAccessControl'}, + "ip": {"key": "ip", "type": "IPAccessControl"}, } - def __init__( - self, - *, - ip: Optional["_models.IPAccessControl"] = None, - **kwargs - ): + def __init__(self, *, ip: Optional["_models.IPAccessControl"] = None, **kwargs): """ :keyword ip: The IP access control properties. :paramtype ip: ~azure.mgmt.media.models.IPAccessControl """ - super(LiveEventPreviewAccessControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip = ip -class LiveEventTranscription(msrest.serialization.Model): +class LiveEventTranscription(_serialization.Model): """Describes the transcription tracks in the output of a live event, generated using speech-to-text transcription. This property is reserved for future use, any value set on this property will be ignored. :ivar language: Specifies the language (locale) to be used for speech-to-text transcription – @@ -7371,9 +7315,9 @@ class LiveEventTranscription(msrest.serialization.Model): """ _attribute_map = { - 'language': {'key': 'language', 'type': 'str'}, - 'input_track_selection': {'key': 'inputTrackSelection', 'type': '[LiveEventInputTrackSelection]'}, - 'output_transcription_track': {'key': 'outputTranscriptionTrack', 'type': 'LiveEventOutputTranscriptionTrack'}, + "language": {"key": "language", "type": "str"}, + "input_track_selection": {"key": "inputTrackSelection", "type": "[LiveEventInputTrackSelection]"}, + "output_transcription_track": {"key": "outputTranscriptionTrack", "type": "LiveEventOutputTranscriptionTrack"}, } def __init__( @@ -7400,13 +7344,13 @@ def __init__( :paramtype output_transcription_track: ~azure.mgmt.media.models.LiveEventOutputTranscriptionTrack """ - super(LiveEventTranscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.language = language self.input_track_selection = input_track_selection self.output_transcription_track = output_transcription_track -class LiveOutput(ProxyResource): +class LiveOutput(ProxyResource): # pylint: disable=too-many-instance-attributes """The Live Output. Variables are only populated by the server, and will be ignored when sending a request. @@ -7430,6 +7374,12 @@ class LiveOutput(ProxyResource): maximum content length for the rewind window. For example, use PT1H30M to indicate 1 hour and 30 minutes of archive window. :vartype archive_window_length: ~datetime.timedelta + :ivar rewind_window_length: ISO 8601 time between 1 minute to the duration of + archiveWindowLength to control seek-able window length during Live. The service won't use this + property once LiveOutput stops. The archived VOD will have full content with original + ArchiveWindowLength. For example, use PT1H30M to indicate 1 hour and 30 minutes of rewind + window length. Service will use implicit default value 30m only if Live Event enables LL. + :vartype rewind_window_length: ~datetime.timedelta :ivar manifest_name: The manifest file name. If not provided, the service will generate one automatically. :vartype manifest_name: str @@ -7437,7 +7387,7 @@ class LiveOutput(ProxyResource): :vartype hls: ~azure.mgmt.media.models.Hls :ivar output_snap_time: The initial timestamp that the live output will start at, any content before this value will not be archived. - :vartype output_snap_time: long + :vartype output_snap_time: int :ivar created: The creation time the live output. :vartype created: ~datetime.datetime :ivar last_modified: The time the live output was last modified. @@ -7445,36 +7395,37 @@ class LiveOutput(ProxyResource): :ivar provisioning_state: The provisioning state of the live output. :vartype provisioning_state: str :ivar resource_state: The resource state of the live output. Known values are: "Creating", - "Running", "Deleting". + "Running", and "Deleting". :vartype resource_state: str or ~azure.mgmt.media.models.LiveOutputResourceState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'resource_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "resource_state": {"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'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'asset_name': {'key': 'properties.assetName', 'type': 'str'}, - 'archive_window_length': {'key': 'properties.archiveWindowLength', 'type': 'duration'}, - 'manifest_name': {'key': 'properties.manifestName', 'type': 'str'}, - 'hls': {'key': 'properties.hls', 'type': 'Hls'}, - 'output_snap_time': {'key': 'properties.outputSnapTime', 'type': 'long'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'resource_state': {'key': 'properties.resourceState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "asset_name": {"key": "properties.assetName", "type": "str"}, + "archive_window_length": {"key": "properties.archiveWindowLength", "type": "duration"}, + "rewind_window_length": {"key": "properties.rewindWindowLength", "type": "duration"}, + "manifest_name": {"key": "properties.manifestName", "type": "str"}, + "hls": {"key": "properties.hls", "type": "Hls"}, + "output_snap_time": {"key": "properties.outputSnapTime", "type": "int"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "resource_state": {"key": "properties.resourceState", "type": "str"}, } def __init__( @@ -7483,6 +7434,7 @@ def __init__( description: Optional[str] = None, asset_name: Optional[str] = None, archive_window_length: Optional[datetime.timedelta] = None, + rewind_window_length: Optional[datetime.timedelta] = None, manifest_name: Optional[str] = None, hls: Optional["_models.Hls"] = None, output_snap_time: Optional[int] = None, @@ -7498,6 +7450,12 @@ def __init__( the maximum content length for the rewind window. For example, use PT1H30M to indicate 1 hour and 30 minutes of archive window. :paramtype archive_window_length: ~datetime.timedelta + :keyword rewind_window_length: ISO 8601 time between 1 minute to the duration of + archiveWindowLength to control seek-able window length during Live. The service won't use this + property once LiveOutput stops. The archived VOD will have full content with original + ArchiveWindowLength. For example, use PT1H30M to indicate 1 hour and 30 minutes of rewind + window length. Service will use implicit default value 30m only if Live Event enables LL. + :paramtype rewind_window_length: ~datetime.timedelta :keyword manifest_name: The manifest file name. If not provided, the service will generate one automatically. :paramtype manifest_name: str @@ -7505,13 +7463,14 @@ def __init__( :paramtype hls: ~azure.mgmt.media.models.Hls :keyword output_snap_time: The initial timestamp that the live output will start at, any content before this value will not be archived. - :paramtype output_snap_time: long + :paramtype output_snap_time: int """ - super(LiveOutput, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.description = description self.asset_name = asset_name self.archive_window_length = archive_window_length + self.rewind_window_length = rewind_window_length self.manifest_name = manifest_name self.hls = hls self.output_snap_time = output_snap_time @@ -7521,7 +7480,7 @@ def __init__( self.resource_state = None -class LiveOutputListResult(msrest.serialization.Model): +class LiveOutputListResult(_serialization.Model): """The LiveOutput list result. :ivar value: The result of the List LiveOutput operation. @@ -7534,9 +7493,9 @@ class LiveOutputListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LiveOutput]'}, - 'odata_count': {'key': '@odata\\.count', 'type': 'int'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[LiveOutput]"}, + "odata_count": {"key": "@odata\\.count", "type": "int"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( @@ -7556,13 +7515,13 @@ def __init__( incomplete list of live outputs. :paramtype odata_next_link: str """ - super(LiveOutputListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_count = odata_count self.odata_next_link = odata_next_link -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """A diagnostic log emitted by service. Variables are only populated by the server, and will be ignored when sending a request. @@ -7576,30 +7535,26 @@ class LogSpecification(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'blob_duration': {'readonly': True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "blob_duration": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LogSpecification, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.display_name = None self.blob_duration = None -class MediaService(TrackedResource): +class MediaService(TrackedResource): # pylint: disable=too-many-instance-attributes """A Media Services account. Variables are only populated by the server, and will be ignored when sending a request. @@ -7614,9 +7569,9 @@ class MediaService(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.media.models.SystemData @@ -7626,17 +7581,17 @@ class MediaService(TrackedResource): :vartype media_service_id: str :ivar storage_accounts: The storage accounts for this resource. :vartype storage_accounts: list[~azure.mgmt.media.models.StorageAccount] - :ivar storage_authentication: Known values are: "System", "ManagedIdentity". + :ivar storage_authentication: Known values are: "System" and "ManagedIdentity". :vartype storage_authentication: str or ~azure.mgmt.media.models.StorageAuthentication :ivar encryption: The account encryption properties. :vartype encryption: ~azure.mgmt.media.models.AccountEncryption :ivar key_delivery: The Key Delivery properties for Media Services account. :vartype key_delivery: ~azure.mgmt.media.models.KeyDelivery :ivar public_network_access: Whether or not public network access is allowed for resources - under the Media Services account. Known values are: "Enabled", "Disabled". + under the Media Services account. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.media.models.PublicNetworkAccess :ivar provisioning_state: Provisioning state of the Media Services account. Known values are: - "Failed", "InProgress", "Succeeded". + "Failed", "InProgress", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.media.models.ProvisioningState :ivar private_endpoint_connections: The Private Endpoint Connections created for the Media Service account. @@ -7644,32 +7599,35 @@ class MediaService(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'media_service_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "media_service_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'identity': {'key': 'identity', 'type': 'MediaServiceIdentity'}, - 'media_service_id': {'key': 'properties.mediaServiceId', 'type': 'str'}, - 'storage_accounts': {'key': 'properties.storageAccounts', 'type': '[StorageAccount]'}, - 'storage_authentication': {'key': 'properties.storageAuthentication', 'type': 'str'}, - 'encryption': {'key': 'properties.encryption', 'type': 'AccountEncryption'}, - 'key_delivery': {'key': 'properties.keyDelivery', 'type': 'KeyDelivery'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "identity": {"key": "identity", "type": "MediaServiceIdentity"}, + "media_service_id": {"key": "properties.mediaServiceId", "type": "str"}, + "storage_accounts": {"key": "properties.storageAccounts", "type": "[StorageAccount]"}, + "storage_authentication": {"key": "properties.storageAuthentication", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "AccountEncryption"}, + "key_delivery": {"key": "properties.keyDelivery", "type": "KeyDelivery"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, } def __init__( @@ -7686,25 +7644,25 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The Managed Identity for the Media Services account. :paramtype identity: ~azure.mgmt.media.models.MediaServiceIdentity :keyword storage_accounts: The storage accounts for this resource. :paramtype storage_accounts: list[~azure.mgmt.media.models.StorageAccount] - :keyword storage_authentication: Known values are: "System", "ManagedIdentity". + :keyword storage_authentication: Known values are: "System" and "ManagedIdentity". :paramtype storage_authentication: str or ~azure.mgmt.media.models.StorageAuthentication :keyword encryption: The account encryption properties. :paramtype encryption: ~azure.mgmt.media.models.AccountEncryption :keyword key_delivery: The Key Delivery properties for Media Services account. :paramtype key_delivery: ~azure.mgmt.media.models.KeyDelivery :keyword public_network_access: Whether or not public network access is allowed for resources - under the Media Services account. Known values are: "Enabled", "Disabled". + under the Media Services account. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.media.models.PublicNetworkAccess """ - super(MediaService, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.system_data = None self.identity = identity self.media_service_id = None @@ -7717,7 +7675,7 @@ def __init__( self.private_endpoint_connections = None -class MediaServiceCollection(msrest.serialization.Model): +class MediaServiceCollection(_serialization.Model): """A collection of MediaService items. :ivar value: A collection of MediaService items. @@ -7728,16 +7686,12 @@ class MediaServiceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[MediaService]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MediaService]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.MediaService"]] = None, - odata_next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.MediaService"]] = None, odata_next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of MediaService items. @@ -7746,19 +7700,19 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(MediaServiceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class MediaServiceIdentity(msrest.serialization.Model): +class MediaServiceIdentity(_serialization.Model): """MediaServiceIdentity. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The identity type. + :ivar type: The identity type. Required. :vartype type: str :ivar principal_id: The Principal ID of the identity. :vartype principal_id: str @@ -7770,16 +7724,16 @@ class MediaServiceIdentity(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "type": {"required": True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedManagedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedManagedIdentity}"}, } def __init__( @@ -7790,25 +7744,25 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. + :keyword type: The identity type. Required. :paramtype type: str :keyword user_assigned_identities: The user assigned managed identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.media.models.UserAssignedManagedIdentity] """ - super(MediaServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = None self.tenant_id = None self.user_assigned_identities = user_assigned_identities -class MediaServiceOperationStatus(msrest.serialization.Model): +class MediaServiceOperationStatus(_serialization.Model): """Status of media service operation. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Operation identifier. + :ivar name: Operation identifier. Required. :vartype name: str :ivar id: Operation resource ID. :vartype id: str @@ -7816,24 +7770,24 @@ class MediaServiceOperationStatus(msrest.serialization.Model): :vartype start_time: ~datetime.datetime :ivar end_time: Operation end time. :vartype end_time: ~datetime.datetime - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar error: The error detail. :vartype error: ~azure.mgmt.media.models.ErrorDetail """ _validation = { - 'name': {'required': True}, - 'status': {'required': True}, + "name": {"required": True}, + "status": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( @@ -7841,14 +7795,14 @@ def __init__( *, name: str, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ - :keyword name: Required. Operation identifier. + :keyword name: Operation identifier. Required. :paramtype name: str :keyword id: Operation resource ID. :paramtype id: str @@ -7856,12 +7810,12 @@ def __init__( :paramtype start_time: ~datetime.datetime :keyword end_time: Operation end time. :paramtype end_time: ~datetime.datetime - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword error: The error detail. :paramtype error: ~azure.mgmt.media.models.ErrorDetail """ - super(MediaServiceOperationStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.id = id self.start_time = start_time @@ -7870,12 +7824,12 @@ def __init__( self.error = error -class MediaServiceUpdate(msrest.serialization.Model): +class MediaServiceUpdate(_serialization.Model): """A Media Services account update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar identity: The Managed Identity for the Media Services account. :vartype identity: ~azure.mgmt.media.models.MediaServiceIdentity @@ -7883,17 +7837,17 @@ class MediaServiceUpdate(msrest.serialization.Model): :vartype media_service_id: str :ivar storage_accounts: The storage accounts for this resource. :vartype storage_accounts: list[~azure.mgmt.media.models.StorageAccount] - :ivar storage_authentication: Known values are: "System", "ManagedIdentity". + :ivar storage_authentication: Known values are: "System" and "ManagedIdentity". :vartype storage_authentication: str or ~azure.mgmt.media.models.StorageAuthentication :ivar encryption: The account encryption properties. :vartype encryption: ~azure.mgmt.media.models.AccountEncryption :ivar key_delivery: The Key Delivery properties for Media Services account. :vartype key_delivery: ~azure.mgmt.media.models.KeyDelivery :ivar public_network_access: Whether or not public network access is allowed for resources - under the Media Services account. Known values are: "Enabled", "Disabled". + under the Media Services account. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.media.models.PublicNetworkAccess :ivar provisioning_state: Provisioning state of the Media Services account. Known values are: - "Failed", "InProgress", "Succeeded". + "Failed", "InProgress", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.media.models.ProvisioningState :ivar private_endpoint_connections: The Private Endpoint Connections created for the Media Service account. @@ -7901,22 +7855,25 @@ class MediaServiceUpdate(msrest.serialization.Model): """ _validation = { - 'media_service_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "media_service_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'MediaServiceIdentity'}, - 'media_service_id': {'key': 'properties.mediaServiceId', 'type': 'str'}, - 'storage_accounts': {'key': 'properties.storageAccounts', 'type': '[StorageAccount]'}, - 'storage_authentication': {'key': 'properties.storageAuthentication', 'type': 'str'}, - 'encryption': {'key': 'properties.encryption', 'type': 'AccountEncryption'}, - 'key_delivery': {'key': 'properties.keyDelivery', 'type': 'KeyDelivery'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "MediaServiceIdentity"}, + "media_service_id": {"key": "properties.mediaServiceId", "type": "str"}, + "storage_accounts": {"key": "properties.storageAccounts", "type": "[StorageAccount]"}, + "storage_authentication": {"key": "properties.storageAuthentication", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "AccountEncryption"}, + "key_delivery": {"key": "properties.keyDelivery", "type": "KeyDelivery"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, } def __init__( @@ -7932,23 +7889,23 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword identity: The Managed Identity for the Media Services account. :paramtype identity: ~azure.mgmt.media.models.MediaServiceIdentity :keyword storage_accounts: The storage accounts for this resource. :paramtype storage_accounts: list[~azure.mgmt.media.models.StorageAccount] - :keyword storage_authentication: Known values are: "System", "ManagedIdentity". + :keyword storage_authentication: Known values are: "System" and "ManagedIdentity". :paramtype storage_authentication: str or ~azure.mgmt.media.models.StorageAuthentication :keyword encryption: The account encryption properties. :paramtype encryption: ~azure.mgmt.media.models.AccountEncryption :keyword key_delivery: The Key Delivery properties for Media Services account. :paramtype key_delivery: ~azure.mgmt.media.models.KeyDelivery :keyword public_network_access: Whether or not public network access is allowed for resources - under the Media Services account. Known values are: "Enabled", "Disabled". + under the Media Services account. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.media.models.PublicNetworkAccess """ - super(MediaServiceUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity self.media_service_id = None @@ -7961,7 +7918,7 @@ def __init__( self.private_endpoint_connections = None -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """A metric dimension. Variables are only populated by the server, and will be ignored when sending a request. @@ -7975,30 +7932,26 @@ class MetricDimension(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'to_be_exported_for_shoebox': {'readonly': True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "to_be_exported_for_shoebox": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricDimension, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.display_name = None self.to_be_exported_for_shoebox = None -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """A metric emitted by service. Variables are only populated by the server, and will be ignored when sending a request. @@ -8009,13 +7962,13 @@ class MetricSpecification(msrest.serialization.Model): :vartype display_name: str :ivar display_description: The metric display description. :vartype display_description: str - :ivar unit: The metric unit. Known values are: "Bytes", "Count", "Milliseconds". + :ivar unit: The metric unit. Known values are: "Bytes", "Count", and "Milliseconds". :vartype unit: str or ~azure.mgmt.media.models.MetricUnit - :ivar aggregation_type: The metric aggregation type. Known values are: "Average", "Count", + :ivar aggregation_type: The metric aggregation type. Known values are: "Average", "Count", and "Total". :vartype aggregation_type: str or ~azure.mgmt.media.models.MetricAggregationType :ivar lock_aggregation_type: The metric lock aggregation type. Known values are: "Average", - "Count", "Total". + "Count", and "Total". :vartype lock_aggregation_type: str or ~azure.mgmt.media.models.MetricAggregationType :ivar supported_aggregation_types: Supported aggregation types. :vartype supported_aggregation_types: list[str] @@ -8032,45 +7985,40 @@ class MetricSpecification(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'display_description': {'readonly': True}, - 'unit': {'readonly': True}, - 'aggregation_type': {'readonly': True}, - 'lock_aggregation_type': {'readonly': True}, - 'dimensions': {'readonly': True}, - 'enable_regional_mdm_account': {'readonly': True}, - 'source_mdm_account': {'readonly': True}, - 'source_mdm_namespace': {'readonly': True}, - 'supported_time_grain_types': {'readonly': True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "display_description": {"readonly": True}, + "unit": {"readonly": True}, + "aggregation_type": {"readonly": True}, + "lock_aggregation_type": {"readonly": True}, + "dimensions": {"readonly": True}, + "enable_regional_mdm_account": {"readonly": True}, + "source_mdm_account": {"readonly": True}, + "source_mdm_namespace": {"readonly": True}, + "supported_time_grain_types": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'lock_aggregation_type': {'key': 'lockAggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'enable_regional_mdm_account': {'key': 'enableRegionalMdmAccount', 'type': 'bool'}, - 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "lock_aggregation_type": {"key": "lockAggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "enable_regional_mdm_account": {"key": "enableRegionalMdmAccount", "type": "bool"}, + "source_mdm_account": {"key": "sourceMdmAccount", "type": "str"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, } - def __init__( - self, - *, - supported_aggregation_types: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, supported_aggregation_types: Optional[List[str]] = None, **kwargs): """ :keyword supported_aggregation_types: Supported aggregation types. :paramtype supported_aggregation_types: list[str] """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display_name = None self.display_description = None @@ -8088,23 +8036,23 @@ def __init__( class MultiBitrateFormat(Format): """Describes the properties for producing a collection of GOP aligned multi-bitrate files. The default behavior is to produce one output file for each video layer which is muxed together with all the audios. The exact output files produced can be controlled by specifying the outputFiles collection. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: Mp4Format, TransportStreamFormat. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + Mp4Format, TransportStreamFormat All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str :ivar output_files: The list of output files to produce. Each entry in the list is a set of audio and video layer labels to be muxed together . @@ -8112,46 +8060,42 @@ class MultiBitrateFormat(Format): """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, - 'output_files': {'key': 'outputFiles', 'type': '[OutputFile]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, + "output_files": {"key": "outputFiles", "type": "[OutputFile]"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.Mp4Format': 'Mp4Format', '#Microsoft.Media.TransportStreamFormat': 'TransportStreamFormat'} - } - - def __init__( - self, - *, - filename_pattern: str, - output_files: Optional[List["_models.OutputFile"]] = None, - **kwargs - ): - """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + "odata_type": { + "#Microsoft.Media.Mp4Format": "Mp4Format", + "#Microsoft.Media.TransportStreamFormat": "TransportStreamFormat", + } + } + + def __init__(self, *, filename_pattern: str, output_files: Optional[List["_models.OutputFile"]] = None, **kwargs): + """ + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str :keyword output_files: The list of output files to produce. Each entry in the list is a set of audio and video layer labels to be muxed together . :paramtype output_files: list[~azure.mgmt.media.models.OutputFile] """ - super(MultiBitrateFormat, self).__init__(filename_pattern=filename_pattern, **kwargs) - self.odata_type = '#Microsoft.Media.MultiBitrateFormat' # type: str + super().__init__(filename_pattern=filename_pattern, **kwargs) + self.odata_type = "#Microsoft.Media.MultiBitrateFormat" # type: str self.output_files = output_files @@ -8160,18 +8104,18 @@ class Mp4Format(MultiBitrateFormat): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str :ivar output_files: The list of output files to produce. Each entry in the list is a set of audio and video layer labels to be muxed together . @@ -8179,45 +8123,38 @@ class Mp4Format(MultiBitrateFormat): """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, - 'output_files': {'key': 'outputFiles', 'type': '[OutputFile]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, + "output_files": {"key": "outputFiles", "type": "[OutputFile]"}, } - def __init__( - self, - *, - filename_pattern: str, - output_files: Optional[List["_models.OutputFile"]] = None, - **kwargs - ): + def __init__(self, *, filename_pattern: str, output_files: Optional[List["_models.OutputFile"]] = None, **kwargs): """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str :keyword output_files: The list of output files to produce. Each entry in the list is a set of audio and video layer labels to be muxed together . :paramtype output_files: list[~azure.mgmt.media.models.OutputFile] """ - super(Mp4Format, self).__init__(filename_pattern=filename_pattern, output_files=output_files, **kwargs) - self.odata_type = '#Microsoft.Media.Mp4Format' # type: str + super().__init__(filename_pattern=filename_pattern, output_files=output_files, **kwargs) + self.odata_type = "#Microsoft.Media.Mp4Format" # type: str -class NoEncryption(msrest.serialization.Model): +class NoEncryption(_serialization.Model): """Class for NoEncryption scheme. :ivar enabled_protocols: Representing supported protocols. @@ -8225,29 +8162,24 @@ class NoEncryption(msrest.serialization.Model): """ _attribute_map = { - 'enabled_protocols': {'key': 'enabledProtocols', 'type': 'EnabledProtocols'}, + "enabled_protocols": {"key": "enabledProtocols", "type": "EnabledProtocols"}, } - def __init__( - self, - *, - enabled_protocols: Optional["_models.EnabledProtocols"] = None, - **kwargs - ): + def __init__(self, *, enabled_protocols: Optional["_models.EnabledProtocols"] = None, **kwargs): """ :keyword enabled_protocols: Representing supported protocols. :paramtype enabled_protocols: ~azure.mgmt.media.models.EnabledProtocols """ - super(NoEncryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled_protocols = enabled_protocols -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """An operation. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The operation name. + :ivar name: The operation name. Required. :vartype name: str :ivar display: The operation display name. :vartype display: ~azure.mgmt.media.models.OperationDisplay @@ -8257,21 +8189,21 @@ class Operation(msrest.serialization.Model): :vartype properties: ~azure.mgmt.media.models.Properties :ivar is_data_action: Whether the operation applies to data-plane. :vartype is_data_action: bool - :ivar action_type: Indicates the action type. Known values are: "Internal". + :ivar action_type: Indicates the action type. "Internal" :vartype action_type: str or ~azure.mgmt.media.models.ActionType """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Properties'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "Properties"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "action_type": {"key": "actionType", "type": "str"}, } def __init__( @@ -8286,7 +8218,7 @@ def __init__( **kwargs ): """ - :keyword name: Required. The operation name. + :keyword name: The operation name. Required. :paramtype name: str :keyword display: The operation display name. :paramtype display: ~azure.mgmt.media.models.OperationDisplay @@ -8296,10 +8228,10 @@ def __init__( :paramtype properties: ~azure.mgmt.media.models.Properties :keyword is_data_action: Whether the operation applies to data-plane. :paramtype is_data_action: bool - :keyword action_type: Indicates the action type. Known values are: "Internal". + :keyword action_type: Indicates the action type. "Internal" :paramtype action_type: str or ~azure.mgmt.media.models.ActionType """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin @@ -8308,7 +8240,7 @@ def __init__( self.action_type = action_type -class OperationCollection(msrest.serialization.Model): +class OperationCollection(_serialization.Model): """A collection of Operation items. :ivar value: A collection of Operation items. @@ -8316,24 +8248,19 @@ class OperationCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: A collection of Operation items. :paramtype value: list[~azure.mgmt.media.models.Operation] """ - super(OperationCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation details. :ivar provider: The service provider. @@ -8347,10 +8274,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -8372,49 +8299,44 @@ def __init__( :keyword description: The operation description. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OutputFile(msrest.serialization.Model): +class OutputFile(_serialization.Model): """Represents an output file produced. All required parameters must be populated in order to send to Azure. - :ivar labels: Required. The list of labels that describe how the encoder should multiplex video - and audio into an output file. For example, if the encoder is producing two video layers with - labels v1 and v2, and one audio layer with label a1, then an array like '[v1, a1]' tells the - encoder to produce an output file with the video track represented by v1 and the audio track - represented by a1. + :ivar labels: The list of labels that describe how the encoder should multiplex video and audio + into an output file. For example, if the encoder is producing two video layers with labels v1 + and v2, and one audio layer with label a1, then an array like '[v1, a1]' tells the encoder to + produce an output file with the video track represented by v1 and the audio track represented + by a1. Required. :vartype labels: list[str] """ _validation = { - 'labels': {'required': True}, + "labels": {"required": True}, } _attribute_map = { - 'labels': {'key': 'labels', 'type': '[str]'}, + "labels": {"key": "labels", "type": "[str]"}, } - def __init__( - self, - *, - labels: List[str], - **kwargs - ): + def __init__(self, *, labels: List[str], **kwargs): """ - :keyword labels: Required. The list of labels that describe how the encoder should multiplex - video and audio into an output file. For example, if the encoder is producing two video layers - with labels v1 and v2, and one audio layer with label a1, then an array like '[v1, a1]' tells - the encoder to produce an output file with the video track represented by v1 and the audio - track represented by a1. + :keyword labels: The list of labels that describe how the encoder should multiplex video and + audio into an output file. For example, if the encoder is producing two video layers with + labels v1 and v2, and one audio layer with label a1, then an array like '[v1, a1]' tells the + encoder to produce an output file with the video track represented by v1 and the audio track + represented by a1. Required. :paramtype labels: list[str] """ - super(OutputFile, self).__init__(**kwargs) + super().__init__(**kwargs) self.labels = labels @@ -8423,53 +8345,47 @@ class PngFormat(ImageFormat): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, } - def __init__( - self, - *, - filename_pattern: str, - **kwargs - ): + def __init__(self, *, filename_pattern: str, **kwargs): """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str """ - super(PngFormat, self).__init__(filename_pattern=filename_pattern, **kwargs) - self.odata_type = '#Microsoft.Media.PngFormat' # type: str + super().__init__(filename_pattern=filename_pattern, **kwargs) + self.odata_type = "#Microsoft.Media.PngFormat" # type: str class PngImage(Image): @@ -8477,7 +8393,7 @@ class PngImage(Image): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar label: An optional label for the codec. The label can be used to control muxing behavior. :vartype label: str @@ -8487,17 +8403,18 @@ class PngImage(Image): value will follow the input source setting. :vartype key_frame_interval: ~datetime.timedelta :ivar stretch_mode: The resizing mode - how the input video will be resized to fit the desired - output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", "AutoFit". + output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :vartype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :ivar sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :vartype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode - :ivar start: Required. The position in the input video from where to start generating - thumbnails. The value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or - a frame count (For example, 10 to start at the 10th frame), or a relative value to stream - duration (For example, 10% to start at 10% of stream duration). Also supports a macro {Best}, - which tells the encoder to select the best thumbnail from the first few seconds of the video - and will only produce one thumbnail, no matter what other settings are for Step and Range. The - default value is macro {Best}. + :ivar start: The position in the input video from where to start generating thumbnails. The + value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or a frame count + (For example, 10 to start at the 10th frame), or a relative value to stream duration (For + example, 10% to start at 10% of stream duration). Also supports a macro {Best}, which tells the + encoder to select the best thumbnail from the first few seconds of the video and will only + produce one thumbnail, no matter what other settings are for Step and Range. The default value + is macro {Best}. Required. :vartype start: str :ivar step: The intervals at which thumbnails are generated. The value can be in ISO 8601 format (For example, PT05S for one image every 5 seconds), or a frame count (For example, 30 @@ -8523,20 +8440,20 @@ class PngImage(Image): """ _validation = { - 'odata_type': {'required': True}, - 'start': {'required': True}, + "odata_type": {"required": True}, + "start": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'key_frame_interval': {'key': 'keyFrameInterval', 'type': 'duration'}, - 'stretch_mode': {'key': 'stretchMode', 'type': 'str'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'str'}, - 'step': {'key': 'step', 'type': 'str'}, - 'range': {'key': 'range', 'type': 'str'}, - 'layers': {'key': 'layers', 'type': '[PngLayer]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "key_frame_interval": {"key": "keyFrameInterval", "type": "duration"}, + "stretch_mode": {"key": "stretchMode", "type": "str"}, + "sync_mode": {"key": "syncMode", "type": "str"}, + "start": {"key": "start", "type": "str"}, + "step": {"key": "step", "type": "str"}, + "range": {"key": "range", "type": "str"}, + "layers": {"key": "layers", "type": "[PngLayer]"}, } def __init__( @@ -8562,18 +8479,19 @@ def __init__( KeyFrameInterval value will follow the input source setting. :paramtype key_frame_interval: ~datetime.timedelta :keyword stretch_mode: The resizing mode - how the input video will be resized to fit the - desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", + desired output resolution(s). Default is AutoSize. Known values are: "None", "AutoSize", and "AutoFit". :paramtype stretch_mode: str or ~azure.mgmt.media.models.StretchMode - :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", "Vfr". + :keyword sync_mode: The Video Sync Mode. Known values are: "Auto", "Passthrough", "Cfr", and + "Vfr". :paramtype sync_mode: str or ~azure.mgmt.media.models.VideoSyncMode - :keyword start: Required. The position in the input video from where to start generating - thumbnails. The value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or - a frame count (For example, 10 to start at the 10th frame), or a relative value to stream - duration (For example, 10% to start at 10% of stream duration). Also supports a macro {Best}, - which tells the encoder to select the best thumbnail from the first few seconds of the video - and will only produce one thumbnail, no matter what other settings are for Step and Range. The - default value is macro {Best}. + :keyword start: The position in the input video from where to start generating thumbnails. The + value can be in ISO 8601 format (For example, PT05S to start at 5 seconds), or a frame count + (For example, 10 to start at the 10th frame), or a relative value to stream duration (For + example, 10% to start at 10% of stream duration). Also supports a macro {Best}, which tells the + encoder to select the best thumbnail from the first few seconds of the video and will only + produce one thumbnail, no matter what other settings are for Step and Range. The default value + is macro {Best}. Required. :paramtype start: str :keyword step: The intervals at which thumbnails are generated. The value can be in ISO 8601 format (For example, PT05S for one image every 5 seconds), or a frame count (For example, 30 @@ -8597,8 +8515,17 @@ def __init__( :keyword layers: A collection of output PNG image layers to be produced by the encoder. :paramtype layers: list[~azure.mgmt.media.models.PngLayer] """ - super(PngImage, self).__init__(label=label, key_frame_interval=key_frame_interval, stretch_mode=stretch_mode, sync_mode=sync_mode, start=start, step=step, range=range, **kwargs) - self.odata_type = '#Microsoft.Media.PngImage' # type: str + super().__init__( + label=label, + key_frame_interval=key_frame_interval, + stretch_mode=stretch_mode, + sync_mode=sync_mode, + start=start, + step=step, + range=range, + **kwargs + ) + self.odata_type = "#Microsoft.Media.PngImage" # type: str self.layers = layers @@ -8619,18 +8546,13 @@ class PngLayer(Layer): """ _attribute_map = { - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, + "label": {"key": "label", "type": "str"}, } def __init__( - self, - *, - width: Optional[str] = None, - height: Optional[str] = None, - label: Optional[str] = None, - **kwargs + self, *, width: Optional[str] = None, height: Optional[str] = None, label: Optional[str] = None, **kwargs ): """ :keyword width: The width of the output video for this layer. The value can be absolute (in @@ -8645,33 +8567,33 @@ def __init__( different video and audio layers, or in naming the output file. :paramtype label: str """ - super(PngLayer, self).__init__(width=width, height=height, label=label, **kwargs) + super().__init__(width=width, height=height, label=label, **kwargs) -class PresentationTimeRange(msrest.serialization.Model): +class PresentationTimeRange(_serialization.Model): """The presentation time range, this is asset related and not recommended for Account Filter. :ivar start_timestamp: The absolute start time boundary. - :vartype start_timestamp: long + :vartype start_timestamp: int :ivar end_timestamp: The absolute end time boundary. - :vartype end_timestamp: long + :vartype end_timestamp: int :ivar presentation_window_duration: The relative to end sliding window. - :vartype presentation_window_duration: long + :vartype presentation_window_duration: int :ivar live_backoff_duration: The relative to end right edge. - :vartype live_backoff_duration: long + :vartype live_backoff_duration: int :ivar timescale: The time scale of time stamps. - :vartype timescale: long + :vartype timescale: int :ivar force_end_timestamp: The indicator of forcing existing of end time stamp. :vartype force_end_timestamp: bool """ _attribute_map = { - 'start_timestamp': {'key': 'startTimestamp', 'type': 'long'}, - 'end_timestamp': {'key': 'endTimestamp', 'type': 'long'}, - 'presentation_window_duration': {'key': 'presentationWindowDuration', 'type': 'long'}, - 'live_backoff_duration': {'key': 'liveBackoffDuration', 'type': 'long'}, - 'timescale': {'key': 'timescale', 'type': 'long'}, - 'force_end_timestamp': {'key': 'forceEndTimestamp', 'type': 'bool'}, + "start_timestamp": {"key": "startTimestamp", "type": "int"}, + "end_timestamp": {"key": "endTimestamp", "type": "int"}, + "presentation_window_duration": {"key": "presentationWindowDuration", "type": "int"}, + "live_backoff_duration": {"key": "liveBackoffDuration", "type": "int"}, + "timescale": {"key": "timescale", "type": "int"}, + "force_end_timestamp": {"key": "forceEndTimestamp", "type": "bool"}, } def __init__( @@ -8687,19 +8609,19 @@ def __init__( ): """ :keyword start_timestamp: The absolute start time boundary. - :paramtype start_timestamp: long + :paramtype start_timestamp: int :keyword end_timestamp: The absolute end time boundary. - :paramtype end_timestamp: long + :paramtype end_timestamp: int :keyword presentation_window_duration: The relative to end sliding window. - :paramtype presentation_window_duration: long + :paramtype presentation_window_duration: int :keyword live_backoff_duration: The relative to end right edge. - :paramtype live_backoff_duration: long + :paramtype live_backoff_duration: int :keyword timescale: The time scale of time stamps. - :paramtype timescale: long + :paramtype timescale: int :keyword force_end_timestamp: The indicator of forcing existing of end time stamp. :paramtype force_end_timestamp: bool """ - super(PresentationTimeRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_timestamp = start_timestamp self.end_timestamp = end_timestamp self.presentation_window_duration = presentation_window_duration @@ -8708,17 +8630,17 @@ def __init__( self.force_end_timestamp = force_end_timestamp -class PresetConfigurations(msrest.serialization.Model): +class PresetConfigurations(_serialization.Model): """An object of optional configuration settings for encoder. :ivar complexity: Allows you to configure the encoder settings to control the balance between speed and quality. Example: set Complexity as Speed for faster encoding but less compression - efficiency. Known values are: "Speed", "Balanced", "Quality". + efficiency. Known values are: "Speed", "Balanced", and "Quality". :vartype complexity: str or ~azure.mgmt.media.models.Complexity :ivar interleave_output: Sets the interleave mode of the output to control how audio and video are stored in the container format. Example: set InterleavedOutput as NonInterleavedOutput to produce audio-only and video-only outputs in separate MP4 files. Known values are: - "NonInterleavedOutput", "InterleavedOutput". + "NonInterleavedOutput" and "InterleavedOutput". :vartype interleave_output: str or ~azure.mgmt.media.models.InterleaveOutput :ivar key_frame_interval_in_seconds: The key frame interval in seconds. Example: set KeyFrameIntervalInSeconds as 2 to reduce the playback buffering for some players. @@ -8743,14 +8665,14 @@ class PresetConfigurations(msrest.serialization.Model): """ _attribute_map = { - 'complexity': {'key': 'complexity', 'type': 'str'}, - 'interleave_output': {'key': 'interleaveOutput', 'type': 'str'}, - 'key_frame_interval_in_seconds': {'key': 'keyFrameIntervalInSeconds', 'type': 'float'}, - 'max_bitrate_bps': {'key': 'maxBitrateBps', 'type': 'int'}, - 'max_height': {'key': 'maxHeight', 'type': 'int'}, - 'max_layers': {'key': 'maxLayers', 'type': 'int'}, - 'min_bitrate_bps': {'key': 'minBitrateBps', 'type': 'int'}, - 'min_height': {'key': 'minHeight', 'type': 'int'}, + "complexity": {"key": "complexity", "type": "str"}, + "interleave_output": {"key": "interleaveOutput", "type": "str"}, + "key_frame_interval_in_seconds": {"key": "keyFrameIntervalInSeconds", "type": "float"}, + "max_bitrate_bps": {"key": "maxBitrateBps", "type": "int"}, + "max_height": {"key": "maxHeight", "type": "int"}, + "max_layers": {"key": "maxLayers", "type": "int"}, + "min_bitrate_bps": {"key": "minBitrateBps", "type": "int"}, + "min_height": {"key": "minHeight", "type": "int"}, } def __init__( @@ -8769,12 +8691,12 @@ def __init__( """ :keyword complexity: Allows you to configure the encoder settings to control the balance between speed and quality. Example: set Complexity as Speed for faster encoding but less - compression efficiency. Known values are: "Speed", "Balanced", "Quality". + compression efficiency. Known values are: "Speed", "Balanced", and "Quality". :paramtype complexity: str or ~azure.mgmt.media.models.Complexity :keyword interleave_output: Sets the interleave mode of the output to control how audio and video are stored in the container format. Example: set InterleavedOutput as NonInterleavedOutput to produce audio-only and video-only outputs in separate MP4 files. Known - values are: "NonInterleavedOutput", "InterleavedOutput". + values are: "NonInterleavedOutput" and "InterleavedOutput". :paramtype interleave_output: str or ~azure.mgmt.media.models.InterleaveOutput :keyword key_frame_interval_in_seconds: The key frame interval in seconds. Example: set KeyFrameIntervalInSeconds as 2 to reduce the playback buffering for some players. @@ -8797,7 +8719,7 @@ def __init__( to avoid output layers of smaller resolutions like 180P. :paramtype min_height: int """ - super(PresetConfigurations, self).__init__(**kwargs) + super().__init__(**kwargs) self.complexity = complexity self.interleave_output = interleave_output self.key_frame_interval_in_seconds = key_frame_interval_in_seconds @@ -8808,7 +8730,7 @@ def __init__( self.min_height = min_height -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -8818,20 +8740,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -8855,25 +8773,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.media.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.media.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -8891,13 +8812,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.media.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -8905,20 +8826,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.media.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -8944,39 +8860,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } - def __init__( - self, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -8984,28 +8895,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.media.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.media.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. :vartype description: str @@ -9015,9 +8921,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( @@ -9030,7 +8936,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.media.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. :paramtype description: str @@ -9038,13 +8944,13 @@ def __init__( updates on the consumer. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class Properties(msrest.serialization.Model): +class Properties(_serialization.Model): """The service specification property. Variables are only populated by the server, and will be ignored when sending a request. @@ -9054,24 +8960,20 @@ class Properties(msrest.serialization.Model): """ _validation = { - 'service_specification': {'readonly': True}, + "service_specification": {"readonly": True}, } _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Properties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_specification = None -class Rectangle(msrest.serialization.Model): +class Rectangle(_serialization.Model): """Describes the properties of a rectangular window applied to the input media before processing it. :ivar left: The number of pixels from the left-margin. This can be absolute pixel value (e.g @@ -9089,10 +8991,10 @@ class Rectangle(msrest.serialization.Model): """ _attribute_map = { - 'left': {'key': 'left', 'type': 'str'}, - 'top': {'key': 'top', 'type': 'str'}, - 'width': {'key': 'width', 'type': 'str'}, - 'height': {'key': 'height', 'type': 'str'}, + "left": {"key": "left", "type": "str"}, + "top": {"key": "top", "type": "str"}, + "width": {"key": "width", "type": "str"}, + "height": {"key": "height", "type": "str"}, } def __init__( @@ -9118,14 +9020,14 @@ def __init__( value (e.g 100), or relative to the size of the video (For example, 50%). :paramtype height: str """ - super(Rectangle, self).__init__(**kwargs) + super().__init__(**kwargs) self.left = left self.top = top self.width = width self.height = height -class ResourceIdentity(msrest.serialization.Model): +class ResourceIdentity(_serialization.Model): """ResourceIdentity. All required parameters must be populated in order to send to Azure. @@ -9133,36 +9035,30 @@ class ResourceIdentity(msrest.serialization.Model): :ivar user_assigned_identity: The user assigned managed identity's ARM ID to use when accessing a resource. :vartype user_assigned_identity: str - :ivar use_system_assigned_identity: Required. Indicates whether to use System Assigned Managed - Identity. Mutual exclusive with User Assigned Managed Identity. + :ivar use_system_assigned_identity: Indicates whether to use System Assigned Managed Identity. + Mutual exclusive with User Assigned Managed Identity. Required. :vartype use_system_assigned_identity: bool """ _validation = { - 'use_system_assigned_identity': {'required': True}, + "use_system_assigned_identity": {"required": True}, } _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - 'use_system_assigned_identity': {'key': 'useSystemAssignedIdentity', 'type': 'bool'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "use_system_assigned_identity": {"key": "useSystemAssignedIdentity", "type": "bool"}, } - def __init__( - self, - *, - use_system_assigned_identity: bool, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, use_system_assigned_identity: bool, user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword user_assigned_identity: The user assigned managed identity's ARM ID to use when accessing a resource. :paramtype user_assigned_identity: str - :keyword use_system_assigned_identity: Required. Indicates whether to use System Assigned - Managed Identity. Mutual exclusive with User Assigned Managed Identity. + :keyword use_system_assigned_identity: Indicates whether to use System Assigned Managed + Identity. Mutual exclusive with User Assigned Managed Identity. Required. :paramtype use_system_assigned_identity: bool """ - super(ResourceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity self.use_system_assigned_identity = use_system_assigned_identity @@ -9172,18 +9068,18 @@ class SelectAudioTrackByAttribute(AudioTrackDescriptor): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar channel_mapping: Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. Known values are: "FrontLeft", - "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", + "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", and "StereoRight". :vartype channel_mapping: str or ~azure.mgmt.media.models.ChannelMapping - :ivar attribute: Required. The TrackAttribute to filter the tracks by. Known values are: - "Bitrate", "Language". + :ivar attribute: The TrackAttribute to filter the tracks by. Required. Known values are: + "Bitrate" and "Language". :vartype attribute: str or ~azure.mgmt.media.models.TrackAttribute - :ivar filter: Required. The type of AttributeFilter to apply to the TrackAttribute in order to - select the tracks. Known values are: "All", "Top", "Bottom", "ValueEquals". + :ivar filter: The type of AttributeFilter to apply to the TrackAttribute in order to select the + tracks. Required. Known values are: "All", "Top", "Bottom", and "ValueEquals". :vartype filter: str or ~azure.mgmt.media.models.AttributeFilter :ivar filter_value: The value to filter the tracks by. Only used when AttributeFilter.ValueEquals is specified for the Filter property. @@ -9191,24 +9087,24 @@ class SelectAudioTrackByAttribute(AudioTrackDescriptor): """ _validation = { - 'odata_type': {'required': True}, - 'attribute': {'required': True}, - 'filter': {'required': True}, + "odata_type": {"required": True}, + "attribute": {"required": True}, + "filter": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'channel_mapping': {'key': 'channelMapping', 'type': 'str'}, - 'attribute': {'key': 'attribute', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, - 'filter_value': {'key': 'filterValue', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "channel_mapping": {"key": "channelMapping", "type": "str"}, + "attribute": {"key": "attribute", "type": "str"}, + "filter": {"key": "filter", "type": "str"}, + "filter_value": {"key": "filterValue", "type": "str"}, } def __init__( self, *, attribute: Union[str, "_models.TrackAttribute"], - filter: Union[str, "_models.AttributeFilter"], + filter: Union[str, "_models.AttributeFilter"], # pylint: disable=redefined-builtin channel_mapping: Optional[Union[str, "_models.ChannelMapping"]] = None, filter_value: Optional[str] = None, **kwargs @@ -9216,21 +9112,21 @@ def __init__( """ :keyword channel_mapping: Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. Known values are: "FrontLeft", - "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", + "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", and "StereoRight". :paramtype channel_mapping: str or ~azure.mgmt.media.models.ChannelMapping - :keyword attribute: Required. The TrackAttribute to filter the tracks by. Known values are: - "Bitrate", "Language". + :keyword attribute: The TrackAttribute to filter the tracks by. Required. Known values are: + "Bitrate" and "Language". :paramtype attribute: str or ~azure.mgmt.media.models.TrackAttribute - :keyword filter: Required. The type of AttributeFilter to apply to the TrackAttribute in order - to select the tracks. Known values are: "All", "Top", "Bottom", "ValueEquals". + :keyword filter: The type of AttributeFilter to apply to the TrackAttribute in order to select + the tracks. Required. Known values are: "All", "Top", "Bottom", and "ValueEquals". :paramtype filter: str or ~azure.mgmt.media.models.AttributeFilter :keyword filter_value: The value to filter the tracks by. Only used when AttributeFilter.ValueEquals is specified for the Filter property. :paramtype filter_value: str """ - super(SelectAudioTrackByAttribute, self).__init__(channel_mapping=channel_mapping, **kwargs) - self.odata_type = '#Microsoft.Media.SelectAudioTrackByAttribute' # type: str + super().__init__(channel_mapping=channel_mapping, **kwargs) + self.odata_type = "#Microsoft.Media.SelectAudioTrackByAttribute" # type: str self.attribute = attribute self.filter = filter self.filter_value = filter_value @@ -9241,81 +9137,76 @@ class SelectAudioTrackById(AudioTrackDescriptor): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar channel_mapping: Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. Known values are: "FrontLeft", - "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", + "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", and "StereoRight". :vartype channel_mapping: str or ~azure.mgmt.media.models.ChannelMapping - :ivar track_id: Required. Track identifier to select. - :vartype track_id: long + :ivar track_id: Track identifier to select. Required. + :vartype track_id: int """ _validation = { - 'odata_type': {'required': True}, - 'track_id': {'required': True}, + "odata_type": {"required": True}, + "track_id": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'channel_mapping': {'key': 'channelMapping', 'type': 'str'}, - 'track_id': {'key': 'trackId', 'type': 'long'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "channel_mapping": {"key": "channelMapping", "type": "str"}, + "track_id": {"key": "trackId", "type": "int"}, } def __init__( - self, - *, - track_id: int, - channel_mapping: Optional[Union[str, "_models.ChannelMapping"]] = None, - **kwargs + self, *, track_id: int, channel_mapping: Optional[Union[str, "_models.ChannelMapping"]] = None, **kwargs ): """ :keyword channel_mapping: Optional designation for single channel audio tracks. Can be used to combine the tracks into stereo or multi-channel audio tracks. Known values are: "FrontLeft", - "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", + "FrontRight", "Center", "LowFrequencyEffects", "BackLeft", "BackRight", "StereoLeft", and "StereoRight". :paramtype channel_mapping: str or ~azure.mgmt.media.models.ChannelMapping - :keyword track_id: Required. Track identifier to select. - :paramtype track_id: long + :keyword track_id: Track identifier to select. Required. + :paramtype track_id: int """ - super(SelectAudioTrackById, self).__init__(channel_mapping=channel_mapping, **kwargs) - self.odata_type = '#Microsoft.Media.SelectAudioTrackById' # type: str + super().__init__(channel_mapping=channel_mapping, **kwargs) + self.odata_type = "#Microsoft.Media.SelectAudioTrackById" # type: str self.track_id = track_id class VideoTrackDescriptor(TrackDescriptor): """A TrackSelection to select video tracks. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SelectVideoTrackByAttribute, SelectVideoTrackById. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SelectVideoTrackByAttribute, SelectVideoTrackById All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'#Microsoft.Media.SelectVideoTrackByAttribute': 'SelectVideoTrackByAttribute', '#Microsoft.Media.SelectVideoTrackById': 'SelectVideoTrackById'} + "odata_type": { + "#Microsoft.Media.SelectVideoTrackByAttribute": "SelectVideoTrackByAttribute", + "#Microsoft.Media.SelectVideoTrackById": "SelectVideoTrackById", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(VideoTrackDescriptor, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.VideoTrackDescriptor' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.VideoTrackDescriptor" # type: str class SelectVideoTrackByAttribute(VideoTrackDescriptor): @@ -9323,13 +9214,13 @@ class SelectVideoTrackByAttribute(VideoTrackDescriptor): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar attribute: Required. The TrackAttribute to filter the tracks by. Known values are: - "Bitrate", "Language". + :ivar attribute: The TrackAttribute to filter the tracks by. Required. Known values are: + "Bitrate" and "Language". :vartype attribute: str or ~azure.mgmt.media.models.TrackAttribute - :ivar filter: Required. The type of AttributeFilter to apply to the TrackAttribute in order to - select the tracks. Known values are: "All", "Top", "Bottom", "ValueEquals". + :ivar filter: The type of AttributeFilter to apply to the TrackAttribute in order to select the + tracks. Required. Known values are: "All", "Top", "Bottom", and "ValueEquals". :vartype filter: str or ~azure.mgmt.media.models.AttributeFilter :ivar filter_value: The value to filter the tracks by. Only used when AttributeFilter.ValueEquals is specified for the Filter property. For TrackAttribute.Bitrate, @@ -9339,32 +9230,32 @@ class SelectVideoTrackByAttribute(VideoTrackDescriptor): """ _validation = { - 'odata_type': {'required': True}, - 'attribute': {'required': True}, - 'filter': {'required': True}, + "odata_type": {"required": True}, + "attribute": {"required": True}, + "filter": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'attribute': {'key': 'attribute', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, - 'filter_value': {'key': 'filterValue', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "attribute": {"key": "attribute", "type": "str"}, + "filter": {"key": "filter", "type": "str"}, + "filter_value": {"key": "filterValue", "type": "str"}, } def __init__( self, *, attribute: Union[str, "_models.TrackAttribute"], - filter: Union[str, "_models.AttributeFilter"], + filter: Union[str, "_models.AttributeFilter"], # pylint: disable=redefined-builtin filter_value: Optional[str] = None, **kwargs ): """ - :keyword attribute: Required. The TrackAttribute to filter the tracks by. Known values are: - "Bitrate", "Language". + :keyword attribute: The TrackAttribute to filter the tracks by. Required. Known values are: + "Bitrate" and "Language". :paramtype attribute: str or ~azure.mgmt.media.models.TrackAttribute - :keyword filter: Required. The type of AttributeFilter to apply to the TrackAttribute in order - to select the tracks. Known values are: "All", "Top", "Bottom", "ValueEquals". + :keyword filter: The type of AttributeFilter to apply to the TrackAttribute in order to select + the tracks. Required. Known values are: "All", "Top", "Bottom", and "ValueEquals". :paramtype filter: str or ~azure.mgmt.media.models.AttributeFilter :keyword filter_value: The value to filter the tracks by. Only used when AttributeFilter.ValueEquals is specified for the Filter property. For TrackAttribute.Bitrate, @@ -9372,8 +9263,8 @@ def __init__( TrackAttribute.Language is not supported for video tracks. :paramtype filter_value: str """ - super(SelectVideoTrackByAttribute, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.SelectVideoTrackByAttribute' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.SelectVideoTrackByAttribute" # type: str self.attribute = attribute self.filter = filter self.filter_value = filter_value @@ -9384,38 +9275,33 @@ class SelectVideoTrackById(VideoTrackDescriptor): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar track_id: Required. Track identifier to select. - :vartype track_id: long + :ivar track_id: Track identifier to select. Required. + :vartype track_id: int """ _validation = { - 'odata_type': {'required': True}, - 'track_id': {'required': True}, + "odata_type": {"required": True}, + "track_id": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'track_id': {'key': 'trackId', 'type': 'long'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "track_id": {"key": "trackId", "type": "int"}, } - def __init__( - self, - *, - track_id: int, - **kwargs - ): + def __init__(self, *, track_id: int, **kwargs): """ - :keyword track_id: Required. Track identifier to select. - :paramtype track_id: long + :keyword track_id: Track identifier to select. Required. + :paramtype track_id: int """ - super(SelectVideoTrackById, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.SelectVideoTrackById' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.SelectVideoTrackById" # type: str self.track_id = track_id -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """The service metric specifications. Variables are only populated by the server, and will be ignored when sending a request. @@ -9427,22 +9313,18 @@ class ServiceSpecification(msrest.serialization.Model): """ _validation = { - 'log_specifications': {'readonly': True}, - 'metric_specifications': {'readonly': True}, + "log_specifications": {"readonly": True}, + "metric_specifications": {"readonly": True}, } _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.log_specifications = None self.metric_specifications = None @@ -9452,28 +9334,28 @@ class StandardEncoderPreset(Preset): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar filters: One or more filtering operations that are applied to the input media before encoding. :vartype filters: ~azure.mgmt.media.models.Filters - :ivar codecs: Required. The list of codecs to be used when encoding the input video. + :ivar codecs: The list of codecs to be used when encoding the input video. Required. :vartype codecs: list[~azure.mgmt.media.models.Codec] - :ivar formats: Required. The list of outputs to be produced by the encoder. + :ivar formats: The list of outputs to be produced by the encoder. Required. :vartype formats: list[~azure.mgmt.media.models.Format] """ _validation = { - 'odata_type': {'required': True}, - 'codecs': {'required': True}, - 'formats': {'required': True}, + "odata_type": {"required": True}, + "codecs": {"required": True}, + "formats": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'Filters'}, - 'codecs': {'key': 'codecs', 'type': '[Codec]'}, - 'formats': {'key': 'formats', 'type': '[Format]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filters": {"key": "filters", "type": "Filters"}, + "codecs": {"key": "codecs", "type": "[Codec]"}, + "formats": {"key": "formats", "type": "[Format]"}, } def __init__( @@ -9488,19 +9370,19 @@ def __init__( :keyword filters: One or more filtering operations that are applied to the input media before encoding. :paramtype filters: ~azure.mgmt.media.models.Filters - :keyword codecs: Required. The list of codecs to be used when encoding the input video. + :keyword codecs: The list of codecs to be used when encoding the input video. Required. :paramtype codecs: list[~azure.mgmt.media.models.Codec] - :keyword formats: Required. The list of outputs to be produced by the encoder. + :keyword formats: The list of outputs to be produced by the encoder. Required. :paramtype formats: list[~azure.mgmt.media.models.Format] """ - super(StandardEncoderPreset, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.StandardEncoderPreset' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.StandardEncoderPreset" # type: str self.filters = filters self.codecs = codecs self.formats = formats -class StorageAccount(msrest.serialization.Model): +class StorageAccount(_serialization.Model): """The storage account details. Variables are only populated by the server, and will be ignored when sending a request. @@ -9512,7 +9394,7 @@ class StorageAccount(msrest.serialization.Model): Microsoft.ClassicStorage or Microsoft.Storage). Blob only storage accounts can be added as secondary storage accounts. :vartype id: str - :ivar type: Required. The type of the storage account. Known values are: "Primary", + :ivar type: The type of the storage account. Required. Known values are: "Primary" and "Secondary". :vartype type: str or ~azure.mgmt.media.models.StorageAccountType :ivar identity: The storage account identity. @@ -9522,22 +9404,22 @@ class StorageAccount(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'status': {'readonly': True}, + "type": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'status': {'key': 'status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, type: Union[str, "_models.StorageAccountType"], - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin identity: Optional["_models.ResourceIdentity"] = None, **kwargs ): @@ -9547,54 +9429,57 @@ def __init__( Microsoft.ClassicStorage or Microsoft.Storage). Blob only storage accounts can be added as secondary storage accounts. :paramtype id: str - :keyword type: Required. The type of the storage account. Known values are: "Primary", + :keyword type: The type of the storage account. Required. Known values are: "Primary" and "Secondary". :paramtype type: str or ~azure.mgmt.media.models.StorageAccountType :keyword identity: The storage account identity. :paramtype identity: ~azure.mgmt.media.models.ResourceIdentity """ - super(StorageAccount, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.identity = identity self.status = None -class StorageEncryptedAssetDecryptionData(msrest.serialization.Model): +class StorageEncryptedAssetDecryptionData(_serialization.Model): """Data needed to decrypt asset files encrypted with legacy storage encryption. :ivar key: The Asset File storage encryption key. - :vartype key: bytearray + :vartype key: bytes :ivar asset_file_encryption_metadata: Asset File encryption metadata. :vartype asset_file_encryption_metadata: list[~azure.mgmt.media.models.AssetFileEncryptionMetadata] """ _attribute_map = { - 'key': {'key': 'key', 'type': 'bytearray'}, - 'asset_file_encryption_metadata': {'key': 'assetFileEncryptionMetadata', 'type': '[AssetFileEncryptionMetadata]'}, + "key": {"key": "key", "type": "bytearray"}, + "asset_file_encryption_metadata": { + "key": "assetFileEncryptionMetadata", + "type": "[AssetFileEncryptionMetadata]", + }, } def __init__( self, *, - key: Optional[bytearray] = None, + key: Optional[bytes] = None, asset_file_encryption_metadata: Optional[List["_models.AssetFileEncryptionMetadata"]] = None, **kwargs ): """ :keyword key: The Asset File storage encryption key. - :paramtype key: bytearray + :paramtype key: bytes :keyword asset_file_encryption_metadata: Asset File encryption metadata. :paramtype asset_file_encryption_metadata: list[~azure.mgmt.media.models.AssetFileEncryptionMetadata] """ - super(StorageEncryptedAssetDecryptionData, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.asset_file_encryption_metadata = asset_file_encryption_metadata -class StreamingEndpoint(TrackedResource): +class StreamingEndpoint(TrackedResource): # pylint: disable=too-many-instance-attributes """The streaming endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -9609,9 +9494,9 @@ class StreamingEndpoint(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.media.models.SystemData @@ -9626,7 +9511,7 @@ class StreamingEndpoint(TrackedResource): :ivar access_control: The access control definition of the streaming endpoint. :vartype access_control: ~azure.mgmt.media.models.StreamingEndpointAccessControl :ivar max_cache_age: Max cache age. - :vartype max_cache_age: long + :vartype max_cache_age: int :ivar custom_host_names: The custom host names of the streaming endpoint. :vartype custom_host_names: list[str] :ivar host_name: The streaming endpoint host name. @@ -9640,7 +9525,7 @@ class StreamingEndpoint(TrackedResource): :ivar provisioning_state: The provisioning state of the streaming endpoint. :vartype provisioning_state: str :ivar resource_state: The resource state of the streaming endpoint. Known values are: - "Stopped", "Starting", "Running", "Stopping", "Deleting", "Scaling". + "Stopped", "Starting", "Running", "Stopping", "Deleting", and "Scaling". :vartype resource_state: str or ~azure.mgmt.media.models.StreamingEndpointResourceState :ivar cross_site_access_policies: The streaming endpoint access policies. :vartype cross_site_access_policies: ~azure.mgmt.media.models.CrossSiteAccessPolicies @@ -9653,43 +9538,43 @@ class StreamingEndpoint(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'host_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'resource_state': {'readonly': True}, - 'free_trial_end_time': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'ArmStreamingEndpointCurrentSku'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'scale_units': {'key': 'properties.scaleUnits', 'type': 'int'}, - 'availability_set_name': {'key': 'properties.availabilitySetName', 'type': 'str'}, - 'access_control': {'key': 'properties.accessControl', 'type': 'StreamingEndpointAccessControl'}, - 'max_cache_age': {'key': 'properties.maxCacheAge', 'type': 'long'}, - 'custom_host_names': {'key': 'properties.customHostNames', 'type': '[str]'}, - 'host_name': {'key': 'properties.hostName', 'type': 'str'}, - 'cdn_enabled': {'key': 'properties.cdnEnabled', 'type': 'bool'}, - 'cdn_provider': {'key': 'properties.cdnProvider', 'type': 'str'}, - 'cdn_profile': {'key': 'properties.cdnProfile', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'resource_state': {'key': 'properties.resourceState', 'type': 'str'}, - 'cross_site_access_policies': {'key': 'properties.crossSiteAccessPolicies', 'type': 'CrossSiteAccessPolicies'}, - 'free_trial_end_time': {'key': 'properties.freeTrialEndTime', 'type': 'iso-8601'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "host_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "resource_state": {"readonly": True}, + "free_trial_end_time": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "ArmStreamingEndpointCurrentSku"}, + "description": {"key": "properties.description", "type": "str"}, + "scale_units": {"key": "properties.scaleUnits", "type": "int"}, + "availability_set_name": {"key": "properties.availabilitySetName", "type": "str"}, + "access_control": {"key": "properties.accessControl", "type": "StreamingEndpointAccessControl"}, + "max_cache_age": {"key": "properties.maxCacheAge", "type": "int"}, + "custom_host_names": {"key": "properties.customHostNames", "type": "[str]"}, + "host_name": {"key": "properties.hostName", "type": "str"}, + "cdn_enabled": {"key": "properties.cdnEnabled", "type": "bool"}, + "cdn_provider": {"key": "properties.cdnProvider", "type": "str"}, + "cdn_profile": {"key": "properties.cdnProfile", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "resource_state": {"key": "properties.resourceState", "type": "str"}, + "cross_site_access_policies": {"key": "properties.crossSiteAccessPolicies", "type": "CrossSiteAccessPolicies"}, + "free_trial_end_time": {"key": "properties.freeTrialEndTime", "type": "iso-8601"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, } def __init__( @@ -9711,9 +9596,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword sku: The streaming endpoint sku. :paramtype sku: ~azure.mgmt.media.models.ArmStreamingEndpointCurrentSku @@ -9727,7 +9612,7 @@ def __init__( :keyword access_control: The access control definition of the streaming endpoint. :paramtype access_control: ~azure.mgmt.media.models.StreamingEndpointAccessControl :keyword max_cache_age: Max cache age. - :paramtype max_cache_age: long + :paramtype max_cache_age: int :keyword custom_host_names: The custom host names of the streaming endpoint. :paramtype custom_host_names: list[str] :keyword cdn_enabled: The CDN enabled flag. @@ -9739,7 +9624,7 @@ def __init__( :keyword cross_site_access_policies: The streaming endpoint access policies. :paramtype cross_site_access_policies: ~azure.mgmt.media.models.CrossSiteAccessPolicies """ - super(StreamingEndpoint, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.system_data = None self.sku = sku self.description = description @@ -9760,7 +9645,7 @@ def __init__( self.last_modified = None -class StreamingEndpointAccessControl(msrest.serialization.Model): +class StreamingEndpointAccessControl(_serialization.Model): """Streaming endpoint access control definition. :ivar akamai: The access control of Akamai. @@ -9770,8 +9655,8 @@ class StreamingEndpointAccessControl(msrest.serialization.Model): """ _attribute_map = { - 'akamai': {'key': 'akamai', 'type': 'AkamaiAccessControl'}, - 'ip': {'key': 'ip', 'type': 'IPAccessControl'}, + "akamai": {"key": "akamai", "type": "AkamaiAccessControl"}, + "ip": {"key": "ip", "type": "IPAccessControl"}, } def __init__( @@ -9787,12 +9672,12 @@ def __init__( :keyword ip: The IP access control of the streaming endpoint. :paramtype ip: ~azure.mgmt.media.models.IPAccessControl """ - super(StreamingEndpointAccessControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.akamai = akamai self.ip = ip -class StreamingEndpointListResult(msrest.serialization.Model): +class StreamingEndpointListResult(_serialization.Model): """The streaming endpoint list result. :ivar value: The result of the List StreamingEndpoint operation. @@ -9805,9 +9690,9 @@ class StreamingEndpointListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StreamingEndpoint]'}, - 'odata_count': {'key': '@odata\\.count', 'type': 'int'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StreamingEndpoint]"}, + "odata_count": {"key": "@odata\\.count", "type": "int"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( @@ -9827,13 +9712,13 @@ def __init__( incomplete list of streaming endpoints. :paramtype odata_next_link: str """ - super(StreamingEndpointListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_count = odata_count self.odata_next_link = odata_next_link -class StreamingEndpointSkuInfoListResult(msrest.serialization.Model): +class StreamingEndpointSkuInfoListResult(_serialization.Model): """StreamingEndpointSkuInfoListResult. :ivar value: The result of the List StreamingEndpoint skus. @@ -9841,24 +9726,19 @@ class StreamingEndpointSkuInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmStreamingEndpointSkuInfo]'}, + "value": {"key": "value", "type": "[ArmStreamingEndpointSkuInfo]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmStreamingEndpointSkuInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmStreamingEndpointSkuInfo"]] = None, **kwargs): """ :keyword value: The result of the List StreamingEndpoint skus. :paramtype value: list[~azure.mgmt.media.models.ArmStreamingEndpointSkuInfo] """ - super(StreamingEndpointSkuInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class StreamingEntityScaleUnit(msrest.serialization.Model): +class StreamingEntityScaleUnit(_serialization.Model): """scale units definition. :ivar scale_unit: The scale unit number of the streaming endpoint. @@ -9866,24 +9746,19 @@ class StreamingEntityScaleUnit(msrest.serialization.Model): """ _attribute_map = { - 'scale_unit': {'key': 'scaleUnit', 'type': 'int'}, + "scale_unit": {"key": "scaleUnit", "type": "int"}, } - def __init__( - self, - *, - scale_unit: Optional[int] = None, - **kwargs - ): + def __init__(self, *, scale_unit: Optional[int] = None, **kwargs): """ :keyword scale_unit: The scale unit number of the streaming endpoint. :paramtype scale_unit: int """ - super(StreamingEntityScaleUnit, self).__init__(**kwargs) + super().__init__(**kwargs) self.scale_unit = scale_unit -class StreamingLocator(ProxyResource): +class StreamingLocator(ProxyResource): # pylint: disable=too-many-instance-attributes """A Streaming Locator resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -9926,28 +9801,28 @@ class StreamingLocator(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created": {"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'}, - 'asset_name': {'key': 'properties.assetName', 'type': 'str'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'streaming_locator_id': {'key': 'properties.streamingLocatorId', 'type': 'str'}, - 'streaming_policy_name': {'key': 'properties.streamingPolicyName', 'type': 'str'}, - 'default_content_key_policy_name': {'key': 'properties.defaultContentKeyPolicyName', 'type': 'str'}, - 'content_keys': {'key': 'properties.contentKeys', 'type': '[StreamingLocatorContentKey]'}, - 'alternative_media_id': {'key': 'properties.alternativeMediaId', 'type': 'str'}, - 'filters': {'key': 'properties.filters', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "asset_name": {"key": "properties.assetName", "type": "str"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "end_time": {"key": "properties.endTime", "type": "iso-8601"}, + "streaming_locator_id": {"key": "properties.streamingLocatorId", "type": "str"}, + "streaming_policy_name": {"key": "properties.streamingPolicyName", "type": "str"}, + "default_content_key_policy_name": {"key": "properties.defaultContentKeyPolicyName", "type": "str"}, + "content_keys": {"key": "properties.contentKeys", "type": "[StreamingLocatorContentKey]"}, + "alternative_media_id": {"key": "properties.alternativeMediaId", "type": "str"}, + "filters": {"key": "properties.filters", "type": "[str]"}, } def __init__( @@ -9989,7 +9864,7 @@ def __init__( :keyword filters: A list of asset or account filters which apply to this streaming locator. :paramtype filters: list[str] """ - super(StreamingLocator, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.asset_name = asset_name self.created = None @@ -10003,7 +9878,7 @@ def __init__( self.filters = filters -class StreamingLocatorCollection(msrest.serialization.Model): +class StreamingLocatorCollection(_serialization.Model): """A collection of StreamingLocator items. :ivar value: A collection of StreamingLocator items. @@ -10014,8 +9889,8 @@ class StreamingLocatorCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StreamingLocator]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StreamingLocator]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( @@ -10032,22 +9907,22 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(StreamingLocatorCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class StreamingLocatorContentKey(msrest.serialization.Model): +class StreamingLocatorContentKey(_serialization.Model): """Class for content key in Streaming Locator. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Required. ID of Content Key. + :ivar id: ID of Content Key. Required. :vartype id: str :ivar type: Encryption type of Content Key. Known values are: "CommonEncryptionCenc", - "CommonEncryptionCbcs", "EnvelopeEncryption". + "CommonEncryptionCbcs", and "EnvelopeEncryption". :vartype type: str or ~azure.mgmt.media.models.StreamingLocatorContentKeyType :ivar label_reference_in_streaming_policy: Label of Content Key as specified in the Streaming Policy. @@ -10061,31 +9936,31 @@ class StreamingLocatorContentKey(msrest.serialization.Model): """ _validation = { - 'id': {'required': True}, - 'type': {'readonly': True}, - 'policy_name': {'readonly': True}, - 'tracks': {'readonly': True}, + "id": {"required": True}, + "type": {"readonly": True}, + "policy_name": {"readonly": True}, + "tracks": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'label_reference_in_streaming_policy': {'key': 'labelReferenceInStreamingPolicy', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, - 'tracks': {'key': 'tracks', 'type': '[TrackSelection]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "label_reference_in_streaming_policy": {"key": "labelReferenceInStreamingPolicy", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "policy_name": {"key": "policyName", "type": "str"}, + "tracks": {"key": "tracks", "type": "[TrackSelection]"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin label_reference_in_streaming_policy: Optional[str] = None, value: Optional[str] = None, **kwargs ): """ - :keyword id: Required. ID of Content Key. + :keyword id: ID of Content Key. Required. :paramtype id: str :keyword label_reference_in_streaming_policy: Label of Content Key as specified in the Streaming Policy. @@ -10093,7 +9968,7 @@ def __init__( :keyword value: Value of Content Key. :paramtype value: str """ - super(StreamingLocatorContentKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = None self.label_reference_in_streaming_policy = label_reference_in_streaming_policy @@ -10102,30 +9977,30 @@ def __init__( self.tracks = None -class StreamingPath(msrest.serialization.Model): +class StreamingPath(_serialization.Model): """Class of paths for streaming. All required parameters must be populated in order to send to Azure. - :ivar streaming_protocol: Required. Streaming protocol. Known values are: "Hls", "Dash", - "SmoothStreaming", "Download". + :ivar streaming_protocol: Streaming protocol. Required. Known values are: "Hls", "Dash", + "SmoothStreaming", and "Download". :vartype streaming_protocol: str or ~azure.mgmt.media.models.StreamingPolicyStreamingProtocol - :ivar encryption_scheme: Required. Encryption scheme. Known values are: "NoEncryption", - "EnvelopeEncryption", "CommonEncryptionCenc", "CommonEncryptionCbcs". + :ivar encryption_scheme: Encryption scheme. Required. Known values are: "NoEncryption", + "EnvelopeEncryption", "CommonEncryptionCenc", and "CommonEncryptionCbcs". :vartype encryption_scheme: str or ~azure.mgmt.media.models.EncryptionScheme :ivar paths: Streaming paths for each protocol and encryptionScheme pair. :vartype paths: list[str] """ _validation = { - 'streaming_protocol': {'required': True}, - 'encryption_scheme': {'required': True}, + "streaming_protocol": {"required": True}, + "encryption_scheme": {"required": True}, } _attribute_map = { - 'streaming_protocol': {'key': 'streamingProtocol', 'type': 'str'}, - 'encryption_scheme': {'key': 'encryptionScheme', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[str]'}, + "streaming_protocol": {"key": "streamingProtocol", "type": "str"}, + "encryption_scheme": {"key": "encryptionScheme", "type": "str"}, + "paths": {"key": "paths", "type": "[str]"}, } def __init__( @@ -10137,16 +10012,16 @@ def __init__( **kwargs ): """ - :keyword streaming_protocol: Required. Streaming protocol. Known values are: "Hls", "Dash", - "SmoothStreaming", "Download". + :keyword streaming_protocol: Streaming protocol. Required. Known values are: "Hls", "Dash", + "SmoothStreaming", and "Download". :paramtype streaming_protocol: str or ~azure.mgmt.media.models.StreamingPolicyStreamingProtocol - :keyword encryption_scheme: Required. Encryption scheme. Known values are: "NoEncryption", - "EnvelopeEncryption", "CommonEncryptionCenc", "CommonEncryptionCbcs". + :keyword encryption_scheme: Encryption scheme. Required. Known values are: "NoEncryption", + "EnvelopeEncryption", "CommonEncryptionCenc", and "CommonEncryptionCbcs". :paramtype encryption_scheme: str or ~azure.mgmt.media.models.EncryptionScheme :keyword paths: Streaming paths for each protocol and encryptionScheme pair. :paramtype paths: list[str] """ - super(StreamingPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.streaming_protocol = streaming_protocol self.encryption_scheme = encryption_scheme self.paths = paths @@ -10182,24 +10057,24 @@ class StreamingPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created": {"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'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'default_content_key_policy_name': {'key': 'properties.defaultContentKeyPolicyName', 'type': 'str'}, - 'envelope_encryption': {'key': 'properties.envelopeEncryption', 'type': 'EnvelopeEncryption'}, - 'common_encryption_cenc': {'key': 'properties.commonEncryptionCenc', 'type': 'CommonEncryptionCenc'}, - 'common_encryption_cbcs': {'key': 'properties.commonEncryptionCbcs', 'type': 'CommonEncryptionCbcs'}, - 'no_encryption': {'key': 'properties.noEncryption', 'type': 'NoEncryption'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "default_content_key_policy_name": {"key": "properties.defaultContentKeyPolicyName", "type": "str"}, + "envelope_encryption": {"key": "properties.envelopeEncryption", "type": "EnvelopeEncryption"}, + "common_encryption_cenc": {"key": "properties.commonEncryptionCenc", "type": "CommonEncryptionCenc"}, + "common_encryption_cbcs": {"key": "properties.commonEncryptionCbcs", "type": "CommonEncryptionCbcs"}, + "no_encryption": {"key": "properties.noEncryption", "type": "NoEncryption"}, } def __init__( @@ -10224,7 +10099,7 @@ def __init__( :keyword no_encryption: Configurations of NoEncryption. :paramtype no_encryption: ~azure.mgmt.media.models.NoEncryption """ - super(StreamingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.created = None self.default_content_key_policy_name = default_content_key_policy_name @@ -10234,7 +10109,7 @@ def __init__( self.no_encryption = no_encryption -class StreamingPolicyCollection(msrest.serialization.Model): +class StreamingPolicyCollection(_serialization.Model): """A collection of StreamingPolicy items. :ivar value: A collection of StreamingPolicy items. @@ -10245,8 +10120,8 @@ class StreamingPolicyCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StreamingPolicy]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StreamingPolicy]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( @@ -10263,12 +10138,12 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(StreamingPolicyCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class StreamingPolicyContentKey(msrest.serialization.Model): +class StreamingPolicyContentKey(_serialization.Model): """Class to specify properties of content key. :ivar label: Label can be used to specify Content Key when creating a Streaming Locator. @@ -10280,9 +10155,9 @@ class StreamingPolicyContentKey(msrest.serialization.Model): """ _attribute_map = { - 'label': {'key': 'label', 'type': 'str'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, - 'tracks': {'key': 'tracks', 'type': '[TrackSelection]'}, + "label": {"key": "label", "type": "str"}, + "policy_name": {"key": "policyName", "type": "str"}, + "tracks": {"key": "tracks", "type": "[TrackSelection]"}, } def __init__( @@ -10301,13 +10176,13 @@ def __init__( :keyword tracks: Tracks which use this content key. :paramtype tracks: list[~azure.mgmt.media.models.TrackSelection] """ - super(StreamingPolicyContentKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.label = label self.policy_name = policy_name self.tracks = tracks -class StreamingPolicyContentKeys(msrest.serialization.Model): +class StreamingPolicyContentKeys(_serialization.Model): """Class to specify properties of all content keys in Streaming Policy. :ivar default_key: Default content key for an encryption scheme. @@ -10317,8 +10192,8 @@ class StreamingPolicyContentKeys(msrest.serialization.Model): """ _attribute_map = { - 'default_key': {'key': 'defaultKey', 'type': 'DefaultKey'}, - 'key_to_track_mappings': {'key': 'keyToTrackMappings', 'type': '[StreamingPolicyContentKey]'}, + "default_key": {"key": "defaultKey", "type": "DefaultKey"}, + "key_to_track_mappings": {"key": "keyToTrackMappings", "type": "[StreamingPolicyContentKey]"}, } def __init__( @@ -10334,12 +10209,12 @@ def __init__( :keyword key_to_track_mappings: Representing tracks needs separate content key. :paramtype key_to_track_mappings: list[~azure.mgmt.media.models.StreamingPolicyContentKey] """ - super(StreamingPolicyContentKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_key = default_key self.key_to_track_mappings = key_to_track_mappings -class StreamingPolicyFairPlayConfiguration(msrest.serialization.Model): +class StreamingPolicyFairPlayConfiguration(_serialization.Model): """Class to specify configurations of FairPlay in Streaming Policy. All required parameters must be populated in order to send to Azure. @@ -10352,25 +10227,21 @@ class StreamingPolicyFairPlayConfiguration(msrest.serialization.Model): StreamingLocatorId.AlternativeMediaId, and {ContentKeyId}, which is replaced with the value of identifier of the key being requested. :vartype custom_license_acquisition_url_template: str - :ivar allow_persistent_license: Required. All license to be persistent or not. + :ivar allow_persistent_license: All license to be persistent or not. Required. :vartype allow_persistent_license: bool """ _validation = { - 'allow_persistent_license': {'required': True}, + "allow_persistent_license": {"required": True}, } _attribute_map = { - 'custom_license_acquisition_url_template': {'key': 'customLicenseAcquisitionUrlTemplate', 'type': 'str'}, - 'allow_persistent_license': {'key': 'allowPersistentLicense', 'type': 'bool'}, + "custom_license_acquisition_url_template": {"key": "customLicenseAcquisitionUrlTemplate", "type": "str"}, + "allow_persistent_license": {"key": "allowPersistentLicense", "type": "bool"}, } def __init__( - self, - *, - allow_persistent_license: bool, - custom_license_acquisition_url_template: Optional[str] = None, - **kwargs + self, *, allow_persistent_license: bool, custom_license_acquisition_url_template: Optional[str] = None, **kwargs ): """ :keyword custom_license_acquisition_url_template: Template for the URL of the custom service @@ -10381,15 +10252,15 @@ def __init__( StreamingLocatorId.AlternativeMediaId, and {ContentKeyId}, which is replaced with the value of identifier of the key being requested. :paramtype custom_license_acquisition_url_template: str - :keyword allow_persistent_license: Required. All license to be persistent or not. + :keyword allow_persistent_license: All license to be persistent or not. Required. :paramtype allow_persistent_license: bool """ - super(StreamingPolicyFairPlayConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_license_acquisition_url_template = custom_license_acquisition_url_template self.allow_persistent_license = allow_persistent_license -class StreamingPolicyPlayReadyConfiguration(msrest.serialization.Model): +class StreamingPolicyPlayReadyConfiguration(_serialization.Model): """Class to specify configurations of PlayReady in Streaming Policy. :ivar custom_license_acquisition_url_template: Template for the URL of the custom service @@ -10405,8 +10276,8 @@ class StreamingPolicyPlayReadyConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'custom_license_acquisition_url_template': {'key': 'customLicenseAcquisitionUrlTemplate', 'type': 'str'}, - 'play_ready_custom_attributes': {'key': 'playReadyCustomAttributes', 'type': 'str'}, + "custom_license_acquisition_url_template": {"key": "customLicenseAcquisitionUrlTemplate", "type": "str"}, + "play_ready_custom_attributes": {"key": "playReadyCustomAttributes", "type": "str"}, } def __init__( @@ -10428,12 +10299,12 @@ def __init__( :keyword play_ready_custom_attributes: Custom attributes for PlayReady. :paramtype play_ready_custom_attributes: str """ - super(StreamingPolicyPlayReadyConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_license_acquisition_url_template = custom_license_acquisition_url_template self.play_ready_custom_attributes = play_ready_custom_attributes -class StreamingPolicyWidevineConfiguration(msrest.serialization.Model): +class StreamingPolicyWidevineConfiguration(_serialization.Model): """Class to specify configurations of Widevine in Streaming Policy. :ivar custom_license_acquisition_url_template: Template for the URL of the custom service @@ -10447,15 +10318,10 @@ class StreamingPolicyWidevineConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'custom_license_acquisition_url_template': {'key': 'customLicenseAcquisitionUrlTemplate', 'type': 'str'}, + "custom_license_acquisition_url_template": {"key": "customLicenseAcquisitionUrlTemplate", "type": "str"}, } - def __init__( - self, - *, - custom_license_acquisition_url_template: Optional[str] = None, - **kwargs - ): + def __init__(self, *, custom_license_acquisition_url_template: Optional[str] = None, **kwargs): """ :keyword custom_license_acquisition_url_template: Template for the URL of the custom service delivering licenses to end user players. Not required when using Azure Media Services for @@ -10466,11 +10332,11 @@ def __init__( identifier of the key being requested. :paramtype custom_license_acquisition_url_template: str """ - super(StreamingPolicyWidevineConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.custom_license_acquisition_url_template = custom_license_acquisition_url_template -class SyncStorageKeysInput(msrest.serialization.Model): +class SyncStorageKeysInput(_serialization.Model): """The input to the sync storage keys request. :ivar id: The ID of the storage account resource. @@ -10478,49 +10344,44 @@ class SyncStorageKeysInput(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ID of the storage account resource. :paramtype id: str """ - super(SyncStorageKeysInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.media.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.media.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( @@ -10538,19 +10399,19 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.media.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.media.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -10566,7 +10427,7 @@ class TextTrack(TrackBase): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar file_name: The file name to the source file. This file is located in the storage container of the asset. @@ -10579,24 +10440,24 @@ class TextTrack(TrackBase): :ivar player_visibility: When PlayerVisibility is set to "Visible", the text track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to "Hidden", the text will not be available to the client. The default - value is "Visible". Known values are: "Hidden", "Visible". + value is "Visible". Known values are: "Hidden" and "Visible". :vartype player_visibility: str or ~azure.mgmt.media.models.Visibility :ivar hls_settings: The HLS specific setting for the text track. :vartype hls_settings: ~azure.mgmt.media.models.HlsSettings """ _validation = { - 'odata_type': {'required': True}, - 'language_code': {'readonly': True}, + "odata_type": {"required": True}, + "language_code": {"readonly": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'file_name': {'key': 'fileName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'language_code': {'key': 'languageCode', 'type': 'str'}, - 'player_visibility': {'key': 'playerVisibility', 'type': 'str'}, - 'hls_settings': {'key': 'hlsSettings', 'type': 'HlsSettings'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "file_name": {"key": "fileName", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "language_code": {"key": "languageCode", "type": "str"}, + "player_visibility": {"key": "playerVisibility", "type": "str"}, + "hls_settings": {"key": "hlsSettings", "type": "HlsSettings"}, } def __init__( @@ -10618,13 +10479,13 @@ def __init__( :keyword player_visibility: When PlayerVisibility is set to "Visible", the text track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to "Hidden", the text will not be available to the client. The default - value is "Visible". Known values are: "Hidden", "Visible". + value is "Visible". Known values are: "Hidden" and "Visible". :paramtype player_visibility: str or ~azure.mgmt.media.models.Visibility :keyword hls_settings: The HLS specific setting for the text track. :paramtype hls_settings: ~azure.mgmt.media.models.HlsSettings """ - super(TextTrack, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.TextTrack' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.TextTrack" # type: str self.file_name = file_name self.display_name = display_name self.language_code = None @@ -10632,14 +10493,14 @@ def __init__( self.hls_settings = hls_settings -class TrackPropertyCondition(msrest.serialization.Model): +class TrackPropertyCondition(_serialization.Model): """Class to specify one track property condition. All required parameters must be populated in order to send to Azure. - :ivar property: Required. Track property type. Known values are: "Unknown", "FourCC". + :ivar property: Track property type. Required. Known values are: "Unknown" and "FourCC". :vartype property: str or ~azure.mgmt.media.models.TrackPropertyType - :ivar operation: Required. Track property condition operation. Known values are: "Unknown", + :ivar operation: Track property condition operation. Required. Known values are: "Unknown" and "Equal". :vartype operation: str or ~azure.mgmt.media.models.TrackPropertyCompareOperation :ivar value: Track property value. @@ -10647,14 +10508,14 @@ class TrackPropertyCondition(msrest.serialization.Model): """ _validation = { - 'property': {'required': True}, - 'operation': {'required': True}, + "property": {"required": True}, + "operation": {"required": True}, } _attribute_map = { - 'property': {'key': 'property', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "property": {"key": "property", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -10666,21 +10527,21 @@ def __init__( **kwargs ): """ - :keyword property: Required. Track property type. Known values are: "Unknown", "FourCC". + :keyword property: Track property type. Required. Known values are: "Unknown" and "FourCC". :paramtype property: str or ~azure.mgmt.media.models.TrackPropertyType - :keyword operation: Required. Track property condition operation. Known values are: "Unknown", - "Equal". + :keyword operation: Track property condition operation. Required. Known values are: "Unknown" + and "Equal". :paramtype operation: str or ~azure.mgmt.media.models.TrackPropertyCompareOperation :keyword value: Track property value. :paramtype value: str """ - super(TrackPropertyCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.property = property self.operation = operation self.value = value -class TrackSelection(msrest.serialization.Model): +class TrackSelection(_serialization.Model): """Class to select a track. :ivar track_selections: TrackSelections is a track property condition list which can specify @@ -10689,21 +10550,16 @@ class TrackSelection(msrest.serialization.Model): """ _attribute_map = { - 'track_selections': {'key': 'trackSelections', 'type': '[TrackPropertyCondition]'}, + "track_selections": {"key": "trackSelections", "type": "[TrackPropertyCondition]"}, } - def __init__( - self, - *, - track_selections: Optional[List["_models.TrackPropertyCondition"]] = None, - **kwargs - ): + def __init__(self, *, track_selections: Optional[List["_models.TrackPropertyCondition"]] = None, **kwargs): """ :keyword track_selections: TrackSelections is a track property condition list which can specify track(s). :paramtype track_selections: list[~azure.mgmt.media.models.TrackPropertyCondition] """ - super(TrackSelection, self).__init__(**kwargs) + super().__init__(**kwargs) self.track_selections = track_selections @@ -10735,31 +10591,27 @@ class Transform(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created': {'readonly': True}, - 'last_modified': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created": {"readonly": True}, + "last_modified": {"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'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'last_modified': {'key': 'properties.lastModified', 'type': 'iso-8601'}, - 'outputs': {'key': 'properties.outputs', 'type': '[TransformOutput]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "description": {"key": "properties.description", "type": "str"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "outputs": {"key": "properties.outputs", "type": "[TransformOutput]"}, } def __init__( - self, - *, - description: Optional[str] = None, - outputs: Optional[List["_models.TransformOutput"]] = None, - **kwargs + self, *, description: Optional[str] = None, outputs: Optional[List["_models.TransformOutput"]] = None, **kwargs ): """ :keyword description: An optional verbose description of the Transform. @@ -10767,7 +10619,7 @@ def __init__( :keyword outputs: An array of one or more TransformOutputs that the Transform should generate. :paramtype outputs: list[~azure.mgmt.media.models.TransformOutput] """ - super(Transform, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.created = None self.description = description @@ -10775,7 +10627,7 @@ def __init__( self.outputs = outputs -class TransformCollection(msrest.serialization.Model): +class TransformCollection(_serialization.Model): """A collection of Transform items. :ivar value: A collection of Transform items. @@ -10786,16 +10638,12 @@ class TransformCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Transform]'}, - 'odata_next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Transform]"}, + "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.Transform"]] = None, - odata_next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Transform"]] = None, odata_next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of Transform items. @@ -10804,12 +10652,12 @@ def __init__( contains too many results to return in one response). :paramtype odata_next_link: str """ - super(TransformCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.odata_next_link = odata_next_link -class TransformOutput(msrest.serialization.Model): +class TransformOutput(_serialization.Model): """Describes the properties of a TransformOutput, which are the rules to be applied while generating the desired output. All required parameters must be populated in order to send to Azure. @@ -10818,25 +10666,25 @@ class TransformOutput(msrest.serialization.Model): service should do when one output fails - either continue to produce other outputs, or, stop the other outputs. The overall Job state will not reflect failures of outputs that are specified with 'ContinueJob'. The default is 'StopProcessingJob'. Known values are: - "StopProcessingJob", "ContinueJob". + "StopProcessingJob" and "ContinueJob". :vartype on_error: str or ~azure.mgmt.media.models.OnErrorType :ivar relative_priority: Sets the relative priority of the TransformOutputs within a Transform. This sets the priority that the service uses for processing TransformOutputs. The default - priority is Normal. Known values are: "Low", "Normal", "High". + priority is Normal. Known values are: "Low", "Normal", and "High". :vartype relative_priority: str or ~azure.mgmt.media.models.Priority - :ivar preset: Required. Preset that describes the operations that will be used to modify, - transcode, or extract insights from the source file to generate the output. + :ivar preset: Preset that describes the operations that will be used to modify, transcode, or + extract insights from the source file to generate the output. Required. :vartype preset: ~azure.mgmt.media.models.Preset """ _validation = { - 'preset': {'required': True}, + "preset": {"required": True}, } _attribute_map = { - 'on_error': {'key': 'onError', 'type': 'str'}, - 'relative_priority': {'key': 'relativePriority', 'type': 'str'}, - 'preset': {'key': 'preset', 'type': 'Preset'}, + "on_error": {"key": "onError", "type": "str"}, + "relative_priority": {"key": "relativePriority", "type": "str"}, + "preset": {"key": "preset", "type": "Preset"}, } def __init__( @@ -10852,17 +10700,17 @@ def __init__( service should do when one output fails - either continue to produce other outputs, or, stop the other outputs. The overall Job state will not reflect failures of outputs that are specified with 'ContinueJob'. The default is 'StopProcessingJob'. Known values are: - "StopProcessingJob", "ContinueJob". + "StopProcessingJob" and "ContinueJob". :paramtype on_error: str or ~azure.mgmt.media.models.OnErrorType :keyword relative_priority: Sets the relative priority of the TransformOutputs within a Transform. This sets the priority that the service uses for processing TransformOutputs. The - default priority is Normal. Known values are: "Low", "Normal", "High". + default priority is Normal. Known values are: "Low", "Normal", and "High". :paramtype relative_priority: str or ~azure.mgmt.media.models.Priority - :keyword preset: Required. Preset that describes the operations that will be used to modify, - transcode, or extract insights from the source file to generate the output. + :keyword preset: Preset that describes the operations that will be used to modify, transcode, + or extract insights from the source file to generate the output. Required. :paramtype preset: ~azure.mgmt.media.models.Preset """ - super(TransformOutput, self).__init__(**kwargs) + super().__init__(**kwargs) self.on_error = on_error self.relative_priority = relative_priority self.preset = preset @@ -10873,18 +10721,18 @@ class TransportStreamFormat(MultiBitrateFormat): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar filename_pattern: Required. The pattern of the file names for the generated output files. - The following macros are supported in the file name: {Basename} - An expansion macro that will - use the name of the input video file. If the base name(the file suffix is not included) of the + :ivar filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the input video file is less than 32 characters long, the base name of input video files will be used. If the length of base name of the input video file exceeds 32 characters, the base name is truncated to the first 32 characters in total length. {Extension} - The appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video - resolution. Any unsubstituted macros will be collapsed and removed from the filename. + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :vartype filename_pattern: str :ivar output_files: The list of output files to produce. Each entry in the list is a set of audio and video layer labels to be muxed together . @@ -10892,45 +10740,38 @@ class TransportStreamFormat(MultiBitrateFormat): """ _validation = { - 'odata_type': {'required': True}, - 'filename_pattern': {'required': True}, + "odata_type": {"required": True}, + "filename_pattern": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'filename_pattern': {'key': 'filenamePattern', 'type': 'str'}, - 'output_files': {'key': 'outputFiles', 'type': '[OutputFile]'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "filename_pattern": {"key": "filenamePattern", "type": "str"}, + "output_files": {"key": "outputFiles", "type": "[OutputFile]"}, } - def __init__( - self, - *, - filename_pattern: str, - output_files: Optional[List["_models.OutputFile"]] = None, - **kwargs - ): + def __init__(self, *, filename_pattern: str, output_files: Optional[List["_models.OutputFile"]] = None, **kwargs): """ - :keyword filename_pattern: Required. The pattern of the file names for the generated output - files. The following macros are supported in the file name: {Basename} - An expansion macro - that will use the name of the input video file. If the base name(the file suffix is not - included) of the input video file is less than 32 characters long, the base name of input video - files will be used. If the length of base name of the input video file exceeds 32 characters, - the base name is truncated to the first 32 characters in total length. {Extension} - The - appropriate extension for this format. {Label} - The label assigned to the codec/layer. {Index} - - A unique index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video - bitrate. Not applicable to thumbnails. {Codec} - The type of the audio/video codec. - {Resolution} - The video resolution. Any unsubstituted macros will be collapsed and removed - from the filename. + :keyword filename_pattern: The pattern of the file names for the generated output files. The + following macros are supported in the file name: {Basename} - An expansion macro that will use + the name of the input video file. If the base name(the file suffix is not included) of the + input video file is less than 32 characters long, the base name of input video files will be + used. If the length of base name of the input video file exceeds 32 characters, the base name + is truncated to the first 32 characters in total length. {Extension} - The appropriate + extension for this format. {Label} - The label assigned to the codec/layer. {Index} - A unique + index for thumbnails. Only applicable to thumbnails. {Bitrate} - The audio/video bitrate. Not + applicable to thumbnails. {Codec} - The type of the audio/video codec. {Resolution} - The video + resolution. Any unsubstituted macros will be collapsed and removed from the filename. Required. :paramtype filename_pattern: str :keyword output_files: The list of output files to produce. Each entry in the list is a set of audio and video layer labels to be muxed together . :paramtype output_files: list[~azure.mgmt.media.models.OutputFile] """ - super(TransportStreamFormat, self).__init__(filename_pattern=filename_pattern, output_files=output_files, **kwargs) - self.odata_type = '#Microsoft.Media.TransportStreamFormat' # type: str + super().__init__(filename_pattern=filename_pattern, output_files=output_files, **kwargs) + self.odata_type = "#Microsoft.Media.TransportStreamFormat" # type: str -class UserAssignedManagedIdentity(msrest.serialization.Model): +class UserAssignedManagedIdentity(_serialization.Model): """UserAssignedManagedIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -10942,22 +10783,18 @@ class UserAssignedManagedIdentity(msrest.serialization.Model): """ _validation = { - 'client_id': {'readonly': True}, - 'principal_id': {'readonly': True}, + "client_id": {"readonly": True}, + "principal_id": {"readonly": True}, } _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedManagedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.client_id = None self.principal_id = None @@ -10967,35 +10804,30 @@ class UtcClipTime(ClipTime): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar time: Required. The time position on the timeline of the input media based on Utc time. + :ivar time: The time position on the timeline of the input media based on Utc time. Required. :vartype time: ~datetime.datetime """ _validation = { - 'odata_type': {'required': True}, - 'time': {'required': True}, + "odata_type": {"required": True}, + "time": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'iso-8601'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, } - def __init__( - self, - *, - time: datetime.datetime, - **kwargs - ): + def __init__(self, *, time: datetime.datetime, **kwargs): """ - :keyword time: Required. The time position on the timeline of the input media based on Utc - time. + :keyword time: The time position on the timeline of the input media based on Utc time. + Required. :paramtype time: ~datetime.datetime """ - super(UtcClipTime, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.UtcClipTime' # type: str + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.UtcClipTime" # type: str self.time = time @@ -11004,7 +10836,7 @@ class VideoAnalyzerPreset(AudioAnalyzerPreset): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str :ivar audio_language: The language for the audio payload in the input using the BCP-47 format of 'language tag-region' (e.g: 'en-US'). If you know the language of your content, it is @@ -11019,7 +10851,7 @@ class VideoAnalyzerPreset(AudioAnalyzerPreset): https://go.microsoft.com/fwlink/?linkid=2109463. :vartype audio_language: str :ivar mode: Determines the set of audio analysis operations to be performed. If unspecified, - the Standard AudioAnalysisMode would be chosen. Known values are: "Standard", "Basic". + the Standard AudioAnalysisMode would be chosen. Known values are: "Standard" and "Basic". :vartype mode: str or ~azure.mgmt.media.models.AudioAnalysisMode :ivar experimental_options: Dictionary containing key value pairs for parameters not exposed in the preset itself. @@ -11031,20 +10863,20 @@ class VideoAnalyzerPreset(AudioAnalyzerPreset): generated. It is recommended that you not use AudioInsightsOnly if you expect some of your inputs to be video only; or use VideoInsightsOnly if you expect some of your inputs to be audio only. Your Jobs in such conditions would error out. Known values are: "AudioInsightsOnly", - "VideoInsightsOnly", "AllInsights". + "VideoInsightsOnly", and "AllInsights". :vartype insights_to_extract: str or ~azure.mgmt.media.models.InsightsType """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'audio_language': {'key': 'audioLanguage', 'type': 'str'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'experimental_options': {'key': 'experimentalOptions', 'type': '{str}'}, - 'insights_to_extract': {'key': 'insightsToExtract', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "audio_language": {"key": "audioLanguage", "type": "str"}, + "mode": {"key": "mode", "type": "str"}, + "experimental_options": {"key": "experimentalOptions", "type": "{str}"}, + "insights_to_extract": {"key": "insightsToExtract", "type": "str"}, } def __init__( @@ -11070,7 +10902,7 @@ def __init__( https://go.microsoft.com/fwlink/?linkid=2109463. :paramtype audio_language: str :keyword mode: Determines the set of audio analysis operations to be performed. If unspecified, - the Standard AudioAnalysisMode would be chosen. Known values are: "Standard", "Basic". + the Standard AudioAnalysisMode would be chosen. Known values are: "Standard" and "Basic". :paramtype mode: str or ~azure.mgmt.media.models.AudioAnalysisMode :keyword experimental_options: Dictionary containing key value pairs for parameters not exposed in the preset itself. @@ -11082,11 +10914,11 @@ def __init__( insights are generated. It is recommended that you not use AudioInsightsOnly if you expect some of your inputs to be video only; or use VideoInsightsOnly if you expect some of your inputs to be audio only. Your Jobs in such conditions would error out. Known values are: - "AudioInsightsOnly", "VideoInsightsOnly", "AllInsights". + "AudioInsightsOnly", "VideoInsightsOnly", and "AllInsights". :paramtype insights_to_extract: str or ~azure.mgmt.media.models.InsightsType """ - super(VideoAnalyzerPreset, self).__init__(audio_language=audio_language, mode=mode, experimental_options=experimental_options, **kwargs) - self.odata_type = '#Microsoft.Media.VideoAnalyzerPreset' # type: str + super().__init__(audio_language=audio_language, mode=mode, experimental_options=experimental_options, **kwargs) + self.odata_type = "#Microsoft.Media.VideoAnalyzerPreset" # type: str self.insights_to_extract = insights_to_extract @@ -11095,12 +10927,13 @@ class VideoOverlay(Overlay): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str - :ivar input_label: Required. The label of the job input which is to be used as an overlay. The - Input must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP - format, or an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See + :ivar input_label: The label of the job input which is to be used as an overlay. The Input must + specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP format, or an + audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See https://aka.ms/mesformats for the complete list of supported audio and video file formats. + Required. :vartype input_label: str :ivar start: The start position, with reference to the input video, at which the overlay starts. The value should be in ISO 8601 format. For example, PT05S to start the overlay at 5 @@ -11135,21 +10968,21 @@ class VideoOverlay(Overlay): """ _validation = { - 'odata_type': {'required': True}, - 'input_label': {'required': True}, + "odata_type": {"required": True}, + "input_label": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, - 'input_label': {'key': 'inputLabel', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'duration'}, - 'end': {'key': 'end', 'type': 'duration'}, - 'fade_in_duration': {'key': 'fadeInDuration', 'type': 'duration'}, - 'fade_out_duration': {'key': 'fadeOutDuration', 'type': 'duration'}, - 'audio_gain_level': {'key': 'audioGainLevel', 'type': 'float'}, - 'position': {'key': 'position', 'type': 'Rectangle'}, - 'opacity': {'key': 'opacity', 'type': 'float'}, - 'crop_rectangle': {'key': 'cropRectangle', 'type': 'Rectangle'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, + "input_label": {"key": "inputLabel", "type": "str"}, + "start": {"key": "start", "type": "duration"}, + "end": {"key": "end", "type": "duration"}, + "fade_in_duration": {"key": "fadeInDuration", "type": "duration"}, + "fade_out_duration": {"key": "fadeOutDuration", "type": "duration"}, + "audio_gain_level": {"key": "audioGainLevel", "type": "float"}, + "position": {"key": "position", "type": "Rectangle"}, + "opacity": {"key": "opacity", "type": "float"}, + "crop_rectangle": {"key": "cropRectangle", "type": "Rectangle"}, } def __init__( @@ -11167,10 +11000,11 @@ def __init__( **kwargs ): """ - :keyword input_label: Required. The label of the job input which is to be used as an overlay. - The Input must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP - format, or an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See + :keyword input_label: The label of the job input which is to be used as an overlay. The Input + must specify exactly one file. You can specify an image file in JPG, PNG, GIF or BMP format, or + an audio file (such as a WAV, MP3, WMA or M4A file), or a video file. See https://aka.ms/mesformats for the complete list of supported audio and video file formats. + Required. :paramtype input_label: str :keyword start: The start position, with reference to the input video, at which the overlay starts. The value should be in ISO 8601 format. For example, PT05S to start the overlay at 5 @@ -11204,8 +11038,16 @@ def __init__( video. :paramtype crop_rectangle: ~azure.mgmt.media.models.Rectangle """ - super(VideoOverlay, self).__init__(input_label=input_label, start=start, end=end, fade_in_duration=fade_in_duration, fade_out_duration=fade_out_duration, audio_gain_level=audio_gain_level, **kwargs) - self.odata_type = '#Microsoft.Media.VideoOverlay' # type: str + super().__init__( + input_label=input_label, + start=start, + end=end, + fade_in_duration=fade_in_duration, + fade_out_duration=fade_out_duration, + audio_gain_level=audio_gain_level, + **kwargs + ) + self.odata_type = "#Microsoft.Media.VideoOverlay" # type: str self.position = position self.opacity = opacity self.crop_rectangle = crop_rectangle @@ -11216,23 +11058,19 @@ class VideoTrack(TrackBase): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. The discriminator for derived types.Constant filled by server. + :ivar odata_type: The discriminator for derived types. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': '@odata\\.type', 'type': 'str'}, + "odata_type": {"key": "@odata\\.type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(VideoTrack, self).__init__(**kwargs) - self.odata_type = '#Microsoft.Media.VideoTrack' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.odata_type = "#Microsoft.Media.VideoTrack" # type: str diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_patch.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_patch.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/__init__.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/__init__.py index 1aefc8bfa770..bf9127707638 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/__init__.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/__init__.py @@ -31,28 +31,29 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountFiltersOperations', - 'Operations', - 'MediaservicesOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', - 'LocationsOperations', - 'MediaServicesOperationStatusesOperations', - 'MediaServicesOperationResultsOperations', - 'AssetsOperations', - 'AssetFiltersOperations', - 'TracksOperations', - 'OperationStatusesOperations', - 'OperationResultsOperations', - 'ContentKeyPoliciesOperations', - 'TransformsOperations', - 'JobsOperations', - 'StreamingPoliciesOperations', - 'StreamingLocatorsOperations', - 'LiveEventsOperations', - 'LiveOutputsOperations', - 'StreamingEndpointsOperations', + "AccountFiltersOperations", + "Operations", + "MediaservicesOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "LocationsOperations", + "MediaServicesOperationStatusesOperations", + "MediaServicesOperationResultsOperations", + "AssetsOperations", + "AssetFiltersOperations", + "TracksOperations", + "OperationStatusesOperations", + "OperationResultsOperations", + "ContentKeyPoliciesOperations", + "TransformsOperations", + "JobsOperations", + "StreamingPoliciesOperations", + "StreamingLocatorsOperations", + "LiveEventsOperations", + "LiveOutputsOperations", + "StreamingEndpointsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_account_filters_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_account_filters_operations.py index 98b1ec0ac03f..f8737f9ca77d 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_account_filters_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_account_filters_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,220 +24,178 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - filter_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - filter_name: str, - *, - json: Optional[_models.AccountFilter] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - filter_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - filter_name: str, - *, - json: Optional[_models.AccountFilter] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) + _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) + class AccountFiltersOperations: """ @@ -254,47 +216,40 @@ def __init__(self, *args, **kwargs): 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.AccountFilterCollection]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.AccountFilter"]: """List Account Filters. List Account Filters in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. 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 AccountFilterCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AccountFilterCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AccountFilter or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AccountFilter] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilterCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountFilterCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -302,16 +257,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -327,10 +273,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -341,54 +285,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, filter_name: str, **kwargs: Any ) -> _models.AccountFilter: """Get an Account Filter. Get the details of an Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccountFilter, or the result of cls(response) + :return: AccountFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AccountFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilter] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountFilter] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +332,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,23 +342,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, filter_name: str, parameters: _models.AccountFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccountFilter: """Create or update an Account Filter. @@ -431,41 +367,114 @@ def create_or_update( Creates or updates an Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AccountFilter + :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: AccountFilter, or the result of cls(response) + :return: AccountFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AccountFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccountFilter: + """Create or update an Account Filter. + + Creates or updates an Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: Union[_models.AccountFilter, IO], + **kwargs: Any + ) -> _models.AccountFilter: + """Create or update an Account Filter. + + Creates or updates an Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AccountFilter 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilter] + 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.AccountFilter] - _json = self._serialize.body(parameters, 'AccountFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountFilter") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -473,10 +482,9 @@ def create_or_update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -485,61 +493,54 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, filter_name: str, **kwargs: Any ) -> None: """Delete an Account Filter. Deletes an Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -547,10 +548,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -561,16 +561,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, filter_name: str, parameters: _models.AccountFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccountFilter: """Update an Account Filter. @@ -578,41 +579,114 @@ def update( Updates an existing Account Filter in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param filter_name: The Account Filter name. + :param filter_name: The Account Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AccountFilter + :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: AccountFilter, or the result of cls(response) + :return: AccountFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AccountFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccountFilter: + """Update an Account Filter. + + Updates an existing Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + filter_name: str, + parameters: Union[_models.AccountFilter, IO], + **kwargs: Any + ) -> _models.AccountFilter: + """Update an Account Filter. + + Updates an existing Account Filter in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param filter_name: The Account Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AccountFilter 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: AccountFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AccountFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountFilter] + 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.AccountFilter] - _json = self._serialize.body(parameters, 'AccountFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountFilter") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -620,10 +694,9 @@ def update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,12 +704,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccountFilter', pipeline_response) + deserialized = self._deserialize("AccountFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/accountFilters/{filterName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_asset_filters_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_asset_filters_operations.py index cab70648d18b..570441edfa6a 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_asset_filters_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_asset_filters_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,230 +24,185 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - *, - json: Optional[_models.AssetFilter] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, asset_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - *, - json: Optional[_models.AssetFilter] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, asset_name: str, filter_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "filterName": _SERIALIZER.url("filter_name", filter_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) + _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) + class AssetFiltersOperations: """ @@ -264,51 +223,45 @@ def __init__(self, *args, **kwargs): 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, - asset_name: str, - **kwargs: Any - ) -> Iterable[_models.AssetFilterCollection]: + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any + ) -> Iterable["_models.AssetFilter"]: """List Asset Filters. List Asset Filters associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AssetFilterCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AssetFilterCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AssetFilter or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AssetFilter] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilterCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetFilterCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -316,17 +269,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - asset_name=asset_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -342,10 +285,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -356,58 +297,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, filter_name: str, **kwargs: Any ) -> _models.AssetFilter: """Get an Asset Filter. Get the details of an Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetFilter, or the result of cls(response) + :return: AssetFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilter] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetFilter] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -415,10 +347,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,17 +357,16 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -444,6 +374,8 @@ def create_or_update( asset_name: str, filter_name: str, parameters: _models.AssetFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AssetFilter: """Create or update an Asset Filter. @@ -451,44 +383,123 @@ def create_or_update( Creates or updates an Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetFilter + :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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AssetFilter: + """Create or update an Asset Filter. + + Creates or updates an Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: Union[_models.AssetFilter, IO], + **kwargs: Any + ) -> _models.AssetFilter: + """Create or update an Asset Filter. + + Creates or updates an Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetFilter 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: AssetFilter, or the result of cls(response) + :return: AssetFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilter] + 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.AssetFilter] - _json = self._serialize.body(parameters, 'AssetFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetFilter") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -496,10 +507,9 @@ def create_or_update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -508,65 +518,57 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - filter_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, filter_name: str, **kwargs: Any ) -> None: """Delete an Asset Filter. Deletes an Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -574,10 +576,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,10 +589,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, @@ -599,6 +599,8 @@ def update( asset_name: str, filter_name: str, parameters: _models.AssetFilter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AssetFilter: """Update an Asset Filter. @@ -606,44 +608,123 @@ def update( Updates an existing Asset Filter associated with the specified Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param filter_name: The Asset Filter name. + :param filter_name: The Asset Filter name. Required. :type filter_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetFilter + :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: AssetFilter, or the result of cls(response) + :return: AssetFilter or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetFilter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AssetFilter: + """Update an Asset Filter. + + Updates an existing Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + filter_name: str, + parameters: Union[_models.AssetFilter, IO], + **kwargs: Any + ) -> _models.AssetFilter: + """Update an Asset Filter. + + Updates an existing Asset Filter associated with the specified Asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param filter_name: The Asset Filter name. Required. + :type filter_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetFilter 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: AssetFilter or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetFilter] + 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.AssetFilter] - _json = self._serialize.body(parameters, 'AssetFilter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetFilter") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, filter_name=filter_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -651,10 +732,9 @@ def update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -662,12 +742,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetFilter', pipeline_response) + deserialized = self._deserialize("AssetFilter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/assetFilters/{filterName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_assets_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_assets_operations.py index f7d132cc79d2..bd568a62fe07 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_assets_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_assets_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,17 +24,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, account_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, @@ -40,335 +47,269 @@ def build_list_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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - *, - json: Optional[_models.Asset] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - *, - json: Optional[_models.Asset] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_container_sas_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - *, - json: Optional[_models.ListContainerSasInput] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_encryption_key_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_streaming_locators_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AssetsOperations: """ @@ -389,7 +330,6 @@ def __init__(self, *args, **kwargs): 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, @@ -399,14 +339,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.AssetCollection]: + ) -> Iterable["_models.Asset"]: """List Assets. List Assets in the Media Services account with optional filtering and ordering. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -418,32 +359,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AssetCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AssetCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Asset or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.Asset] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -451,19 +391,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -479,10 +407,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -493,54 +419,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any - ) -> _models.Asset: + def get(self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any) -> _models.Asset: """Get an Asset. Get the details of an Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Asset, or the result of cls(response) + :return: Asset or the result of cls(response) :rtype: ~azure.mgmt.media.models.Asset - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Asset] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Asset] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +464,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -559,23 +474,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, asset_name: str, parameters: _models.Asset, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Asset: """Create or update an Asset. @@ -583,41 +499,114 @@ def create_or_update( Creates or updates an Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Asset + :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: Asset, or the result of cls(response) + :return: Asset or the result of cls(response) :rtype: ~azure.mgmt.media.models.Asset - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Asset: + """Create or update an Asset. + + Creates or updates an Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: Union[_models.Asset, IO], + **kwargs: Any + ) -> _models.Asset: + """Create or update an Asset. + + Creates or updates an Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Asset 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Asset] + 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.Asset] - _json = self._serialize.body(parameters, 'Asset') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Asset") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -625,10 +614,9 @@ def create_or_update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -637,61 +625,54 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any ) -> None: """Delete an Asset. Deletes an Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -699,10 +680,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -713,16 +693,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, asset_name: str, parameters: _models.Asset, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Asset: """Update an Asset. @@ -730,41 +711,114 @@ def update( Updates an existing Asset in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Asset + :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: Asset, or the result of cls(response) + :return: Asset or the result of cls(response) :rtype: ~azure.mgmt.media.models.Asset - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Asset: + """Update an Asset. + + Updates an existing Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: Union[_models.Asset, IO], + **kwargs: Any + ) -> _models.Asset: + """Update an Asset. + + Updates an existing Asset in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Asset 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: Asset or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Asset] + 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.Asset] - _json = self._serialize.body(parameters, 'Asset') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Asset") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -772,10 +826,9 @@ def update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -783,23 +836,24 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Asset', pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}"} # type: ignore - @distributed_trace + @overload def list_container_sas( self, resource_group_name: str, account_name: str, asset_name: str, parameters: _models.ListContainerSasInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AssetContainerSas: """List the Asset URLs. @@ -808,41 +862,116 @@ def list_container_sas( Asset content. The signatures are derived from the storage account keys. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ListContainerSasInput + :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: AssetContainerSas or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetContainerSas + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_container_sas( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AssetContainerSas: + """List the Asset URLs. + + Lists storage container URLs with shared access signatures (SAS) for uploading and downloading + Asset content. The signatures are derived from the storage account keys. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: AssetContainerSas, or the result of cls(response) + :return: AssetContainerSas or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetContainerSas - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def list_container_sas( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + parameters: Union[_models.ListContainerSasInput, IO], + **kwargs: Any + ) -> _models.AssetContainerSas: + """List the Asset URLs. + + Lists storage container URLs with shared access signatures (SAS) for uploading and downloading + Asset content. The signatures are derived from the storage account keys. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ListContainerSasInput 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: AssetContainerSas or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AssetContainerSas + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetContainerSas] + 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.AssetContainerSas] - _json = self._serialize.body(parameters, 'ListContainerSasInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ListContainerSasInput") request = build_list_container_sas_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_container_sas.metadata['url'], + content=_content, + template_url=self.list_container_sas.metadata["url"], headers=_headers, params=_params, ) @@ -850,10 +979,9 @@ def list_container_sas( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -861,23 +989,18 @@ def list_container_sas( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetContainerSas', pipeline_response) + deserialized = self._deserialize("AssetContainerSas", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_container_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas"} # type: ignore - + list_container_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas"} # type: ignore @distributed_trace def get_encryption_key( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any ) -> _models.StorageEncryptedAssetDecryptionData: """Gets the Asset storage key. @@ -885,35 +1008,33 @@ def get_encryption_key( Media Services API. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageEncryptedAssetDecryptionData, or the result of cls(response) + :return: StorageEncryptedAssetDecryptionData or the result of cls(response) :rtype: ~azure.mgmt.media.models.StorageEncryptedAssetDecryptionData - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageEncryptedAssetDecryptionData] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageEncryptedAssetDecryptionData] - request = build_get_encryption_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_encryption_key.metadata['url'], + template_url=self.get_encryption_key.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1042,9 @@ def get_encryption_key( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,58 +1052,51 @@ def get_encryption_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageEncryptedAssetDecryptionData', pipeline_response) + deserialized = self._deserialize("StorageEncryptedAssetDecryptionData", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_encryption_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey"} # type: ignore - + get_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey"} # type: ignore @distributed_trace def list_streaming_locators( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any ) -> _models.ListStreamingLocatorsResponse: """List Streaming Locators. Lists Streaming Locators which are associated with this asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListStreamingLocatorsResponse, or the result of cls(response) + :return: ListStreamingLocatorsResponse or the result of cls(response) :rtype: ~azure.mgmt.media.models.ListStreamingLocatorsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListStreamingLocatorsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListStreamingLocatorsResponse] - request = build_list_streaming_locators_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_streaming_locators.metadata['url'], + template_url=self.list_streaming_locators.metadata["url"], headers=_headers, params=_params, ) @@ -991,10 +1104,9 @@ def list_streaming_locators( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,12 +1114,11 @@ def list_streaming_locators( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListStreamingLocatorsResponse', pipeline_response) + deserialized = self._deserialize("ListStreamingLocatorsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_streaming_locators.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators"} # type: ignore - + list_streaming_locators.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_content_key_policies_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_content_key_policies_operations.py index 3ed7f7d99159..dc0f532db832 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_content_key_policies_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_content_key_policies_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,17 +24,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, account_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, @@ -40,249 +47,202 @@ def build_list_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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, content_key_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - *, - json: Optional[_models.ContentKeyPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, content_key_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, content_key_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - *, - json: Optional[_models.ContentKeyPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, content_key_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_policy_properties_with_secrets_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, content_key_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}/getPolicyPropertiesWithSecrets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}/getPolicyPropertiesWithSecrets", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "contentKeyPolicyName": _SERIALIZER.url("content_key_policy_name", content_key_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ContentKeyPoliciesOperations: """ @@ -303,7 +263,6 @@ def __init__(self, *args, **kwargs): 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, @@ -313,14 +272,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ContentKeyPolicyCollection]: + ) -> Iterable["_models.ContentKeyPolicy"]: """List Content Key Policies. Lists the Content Key Policies in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -332,33 +292,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContentKeyPolicyCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.ContentKeyPolicyCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.ContentKeyPolicy] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicyCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentKeyPolicyCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -366,19 +324,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -394,10 +340,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -408,54 +352,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, content_key_policy_name: str, **kwargs: Any ) -> _models.ContentKeyPolicy: """Get a Content Key Policy. Get the details of a Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentKeyPolicy, or the result of cls(response) + :return: ContentKeyPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentKeyPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -463,10 +399,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,23 +409,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, content_key_policy_name: str, parameters: _models.ContentKeyPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ContentKeyPolicy: """Create or update an Content Key Policy. @@ -498,41 +434,114 @@ def create_or_update( Create or update a Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy + :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: ContentKeyPolicy, or the result of cls(response) + :return: ContentKeyPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Create or update an Content Key Policy. + + Create or update a Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: Union[_models.ContentKeyPolicy, IO], + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Create or update an Content Key Policy. + + Create or update a Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy 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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicy] + 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.ContentKeyPolicy] - _json = self._serialize.body(parameters, 'ContentKeyPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ContentKeyPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -540,10 +549,9 @@ def create_or_update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,61 +560,54 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, content_key_policy_name: str, **kwargs: Any ) -> None: """Delete a Content Key Policy. Deletes a Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -614,10 +615,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -628,16 +628,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, content_key_policy_name: str, parameters: _models.ContentKeyPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ContentKeyPolicy: """Update a Content Key Policy. @@ -645,41 +646,114 @@ def update( Updates an existing Content Key Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy + :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: ContentKeyPolicy, or the result of cls(response) + :return: ContentKeyPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Update a Content Key Policy. + + Updates an existing Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + content_key_policy_name: str, + parameters: Union[_models.ContentKeyPolicy, IO], + **kwargs: Any + ) -> _models.ContentKeyPolicy: + """Update a Content Key Policy. + + Updates an existing Content Key Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param content_key_policy_name: The Content Key Policy name. Required. + :type content_key_policy_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ContentKeyPolicy 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: ContentKeyPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.ContentKeyPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicy] + 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.ContentKeyPolicy] - _json = self._serialize.body(parameters, 'ContentKeyPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ContentKeyPolicy") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -687,10 +761,9 @@ def update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -698,58 +771,51 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContentKeyPolicy', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}"} # type: ignore @distributed_trace def get_policy_properties_with_secrets( - self, - resource_group_name: str, - account_name: str, - content_key_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, content_key_policy_name: str, **kwargs: Any ) -> _models.ContentKeyPolicyProperties: """Get a Content Key Policy with secrets. Get a Content Key Policy including secret values. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param content_key_policy_name: The Content Key Policy name. + :param content_key_policy_name: The Content Key Policy name. Required. :type content_key_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentKeyPolicyProperties, or the result of cls(response) + :return: ContentKeyPolicyProperties or the result of cls(response) :rtype: ~azure.mgmt.media.models.ContentKeyPolicyProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentKeyPolicyProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentKeyPolicyProperties] - request = build_get_policy_properties_with_secrets_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, content_key_policy_name=content_key_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_policy_properties_with_secrets.metadata['url'], + template_url=self.get_policy_properties_with_secrets.metadata["url"], headers=_headers, params=_params, ) @@ -757,10 +823,9 @@ def get_policy_properties_with_secrets( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -768,12 +833,11 @@ def get_policy_properties_with_secrets( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContentKeyPolicyProperties', pipeline_response) + deserialized = self._deserialize("ContentKeyPolicyProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_policy_properties_with_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}/getPolicyPropertiesWithSecrets"} # type: ignore - + get_policy_properties_with_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/contentKeyPolicies/{contentKeyPolicyName}/getPolicyPropertiesWithSecrets"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_jobs_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_jobs_operations.py index 8fb7138ca1c2..4632171add09 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_jobs_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_jobs_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,18 +24,21 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, account_name: str, transform_name: str, + subscription_id: str, *, filter: Optional[str] = None, orderby: Optional[str] = None, @@ -40,258 +47,206 @@ def build_list_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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, transform_name: str, job_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), - "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - *, - json: Optional[_models.Job] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, transform_name: str, job_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), - "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, transform_name: str, job_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), - "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - *, - json: Optional[_models.Job] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, transform_name: str, job_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), - "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_cancel_job_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, transform_name: str, job_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), - "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class JobsOperations: """ @@ -312,7 +267,6 @@ def __init__(self, *args, **kwargs): 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, @@ -322,16 +276,17 @@ def list( filter: Optional[str] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.JobCollection]: + ) -> Iterable["_models.Job"]: """List Jobs. Lists all of the Jobs for the Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -339,32 +294,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.JobCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Job or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.Job] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JobCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -372,19 +326,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - transform_name=transform_name, - api_version=api_version, - filter=filter, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -400,10 +342,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,58 +354,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, job_name: str, **kwargs: Any ) -> _models.Job: """Get Job. Gets a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.media.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Job] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -473,10 +404,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,17 +414,16 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, @@ -502,6 +431,8 @@ def create( transform_name: str, job_name: str, parameters: _models.Job, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Job: """Create Job. @@ -509,44 +440,123 @@ def create( Creates a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Job + :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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Create Job. + + Creates a Job. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.media.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: Union[_models.Job, IO], + **kwargs: Any + ) -> _models.Job: + """Create Job. + + Creates a Job. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Job 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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + 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.Job] - _json = self._serialize.body(parameters, 'Job') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Job") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +564,9 @@ def create( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -565,62 +574,54 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, job_name: str, **kwargs: Any ) -> None: """Delete Job. Deletes a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -628,10 +629,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -642,10 +642,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, @@ -653,6 +652,8 @@ def update( transform_name: str, job_name: str, parameters: _models.Job, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Job: """Update Job. @@ -662,44 +663,127 @@ def update( ignored. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Job + :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: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.media.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Update Job. + + Update is only supported for description and priority. Updating Priority will take effect when + the Job state is Queued or Scheduled and depending on the timing the priority update may be + ignored. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + job_name: str, + parameters: Union[_models.Job, IO], + **kwargs: Any + ) -> _models.Job: + """Update Job. + + Update is only supported for description and priority. Updating Priority will take effect when + the Job state is Queued or Scheduled and depending on the timing the priority update may be + ignored. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param job_name: The Job name. Required. + :type job_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Job 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: Job or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + 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.Job] - _json = self._serialize.body(parameters, 'Job') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Job") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -707,10 +791,9 @@ def update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -718,62 +801,54 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}"} # type: ignore @distributed_trace def cancel_job( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - transform_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, job_name: str, **kwargs: Any ) -> None: """Cancel Job. Cancel a Job. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param job_name: The Job name. + :param job_name: The Job name. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_cancel_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_job.metadata['url'], + template_url=self.cancel_job.metadata["url"], headers=_headers, params=_params, ) @@ -781,10 +856,9 @@ def cancel_job( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -795,5 +869,4 @@ def cancel_job( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob"} # type: ignore - + cancel_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_events_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_events_operations.py index 8123b3bcf83c..17518a8830c9 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_events_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_events_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,387 +26,450 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, account_name: str, live_event_name: str, + subscription_id: str, *, - json: Optional[_models.LiveEvent] = None, - content: Any = None, auto_start: Optional[bool] = None, **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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if auto_start is not None: - _params['autoStart'] = _SERIALIZER.query("auto_start", auto_start, 'bool') + _params["autoStart"] = _SERIALIZER.query("auto_start", auto_start, "bool") # 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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - live_event_name: str, - *, - json: Optional[_models.LiveEvent] = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_allocate_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any +def build_allocate_request( + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any +def build_start_request( + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - live_event_name: str, - *, - json: Optional[_models.LiveEventActionInput] = None, - content: Any = None, - **kwargs: Any +def build_stop_request( + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_reset_request_initial( - subscription_id: str, +def build_reset_request( + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_async_operation_request( + resource_group_name: str, account_name: str, operation_id: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEventOperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_operation_location_request( resource_group_name: str, account_name: str, live_event_name: str, + operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/operationLocations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class LiveEventsOperations: """ @@ -423,46 +490,40 @@ def __init__(self, *args, **kwargs): 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.LiveEventListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.LiveEvent"]: """List live events. Lists all the live events in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. 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 LiveEventListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.LiveEventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LiveEvent or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.LiveEvent] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEventListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveEventListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -470,16 +531,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -495,10 +547,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -509,54 +559,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> _models.LiveEvent: """Get Live Event. Gets properties of a live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LiveEvent, or the result of cls(response) + :return: LiveEvent or the result of cls(response) :rtype: ~azure.mgmt.media.models.LiveEvent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveEvent] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -564,10 +606,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -575,49 +616,53 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, live_event_name: str, - parameters: _models.LiveEvent, + parameters: Union[_models.LiveEvent, IO], auto_start: Optional[bool] = None, **kwargs: Any ) -> _models.LiveEvent: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] + 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.LiveEvent] - _json = self._serialize.body(parameters, 'LiveEvent') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveEvent") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, + auto_start=auto_start, api_version=api_version, content_type=content_type, json=_json, - auto_start=auto_start, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -625,31 +670,30 @@ def _create_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, @@ -657,6 +701,8 @@ def begin_create( live_event_name: str, parameters: _models.LiveEvent, auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LiveEvent]: """Create Live Event. @@ -664,16 +710,20 @@ def begin_create( Creates a new live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param parameters: Live event properties needed for creation. + :param parameters: Live event properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.LiveEvent :param auto_start: The flag indicates if the resource should be automatically started on creation. Default value is None. :type auto_start: bool + :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 @@ -684,20 +734,104 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either LiveEvent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveEvent] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: IO, + auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LiveEvent]: + """Create Live Event. + + Creates a new live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for creation. Required. + :type parameters: IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 LiveEvent or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: Union[_models.LiveEvent, IO], + auto_start: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[_models.LiveEvent]: + """Create Live Event. + + Creates a new live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for creation. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.media.models.LiveEvent or IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 LiveEvent or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.LiveEvent] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -707,71 +841,72 @@ def begin_create( auto_start=auto_start, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore def _update_initial( self, resource_group_name: str, account_name: str, live_event_name: str, - parameters: _models.LiveEvent, + parameters: Union[_models.LiveEvent, IO], **kwargs: Any ) -> _models.LiveEvent: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] + 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.LiveEvent] - _json = self._serialize.body(parameters, 'LiveEvent') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveEvent") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -779,49 +914,129 @@ def _update_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, account_name: str, live_event_name: str, parameters: _models.LiveEvent, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LiveEvent]: """Updates settings on an existing live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param parameters: Live event properties needed for patch. + :param parameters: Live event properties needed for patch. Required. :type parameters: ~azure.mgmt.media.models.LiveEvent + :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 LiveEvent or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LiveEvent]: + """Updates settings on an existing live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for patch. Required. + :type parameters: 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 LiveEvent or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: Union[_models.LiveEvent, IO], + **kwargs: Any + ) -> LROPoller[_models.LiveEvent]: + """Updates settings on an existing live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: Live event properties needed for patch. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.media.models.LiveEvent 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 @@ -832,20 +1047,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either LiveEvent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveEvent] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveEvent] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.LiveEvent] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -854,66 +1066,55 @@ def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('LiveEvent', pipeline_response) + deserialized = self._deserialize("LiveEvent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -921,39 +1122,35 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete Live Event. Deletes a live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -965,83 +1162,69 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}"} # type: ignore def _allocate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_allocate_request_initial( - subscription_id=self._config.subscription_id, + request = build_allocate_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._allocate_initial.metadata['url'], + template_url=self._allocate_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1049,39 +1232,35 @@ def _allocate_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _allocate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore - + _allocate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore @distributed_trace - def begin_allocate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + def begin_allocate( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> LROPoller[None]: """Allocate resources for a live event. A live event is in StandBy state after allocation completes, and is ready to start. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -1093,83 +1272,69 @@ def begin_allocate( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._allocate_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_allocate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore + begin_allocate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1177,29 +1342,24 @@ def _start_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> LROPoller[None]: """Start Live Event. @@ -1207,10 +1367,11 @@ def begin_start( # pylint: disable=inconsistent-return-statements completes. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -1222,88 +1383,86 @@ def begin_start( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, live_event_name: str, - parameters: _models.LiveEventActionInput, + parameters: Union[_models.LiveEventActionInput, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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[None] - _json = self._serialize.body(parameters, 'LiveEventActionInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveEventActionInput") - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + request = build_stop_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._stop_initial.metadata['url'], + content=_content, + template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1311,29 +1470,30 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore - - @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements + @overload + def begin_stop( self, resource_group_name: str, account_name: str, live_event_name: str, parameters: _models.LiveEventActionInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Stop Live Event. @@ -1341,13 +1501,17 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Stops a running live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param parameters: LiveEvent stop parameters. + :param parameters: LiveEvent stop parameters. Required. :type parameters: ~azure.mgmt.media.models.LiveEventActionInput + :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 @@ -1358,20 +1522,95 @@ def begin_stop( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Stop Live Event. + + Stops a running live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: LiveEvent stop parameters. Required. + :type parameters: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_stop( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + parameters: Union[_models.LiveEventActionInput, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Stop Live Event. + + Stops a running live event. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param parameters: LiveEvent stop parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.LiveEventActionInput 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, @@ -1380,64 +1619,53 @@ def begin_stop( # pylint: disable=inconsistent-return-statements parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop"} # type: ignore def _reset_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_reset_request_initial( - subscription_id=self._config.subscription_id, + request = build_reset_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._reset_initial.metadata['url'], + template_url=self._reset_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1445,29 +1673,24 @@ def _reset_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _reset_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore - + _reset_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore @distributed_trace - def begin_reset( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - **kwargs: Any + def begin_reset( + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any ) -> LROPoller[None]: """Reset Live Event. @@ -1476,10 +1699,11 @@ def begin_reset( # pylint: disable=inconsistent-return-statements locators created on these assets are unaffected. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_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. @@ -1491,53 +1715,175 @@ def begin_reset( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._reset_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_reset.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore + begin_reset.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset"} # type: ignore + + @distributed_trace + def async_operation( + self, resource_group_name: str, account_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: + """Get operation status. + + Get a live event operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AsyncOperationResult or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AsyncOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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.AsyncOperationResult] + + request = build_async_operation_request( + resource_group_name=resource_group_name, + account_name=account_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.async_operation.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 + ) + + 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("AsyncOperationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEventOperations/{operationId}"} # type: ignore + + @distributed_trace + def operation_location( + self, resource_group_name: str, account_name: str, live_event_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.LiveEvent]: + """Get operation status. + + Get a live event operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LiveEvent or None or the result of cls(response) + :rtype: ~azure.mgmt.media.models.LiveEvent or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[Optional[_models.LiveEvent]] + + request = build_operation_location_request( + resource_group_name=resource_group_name, + account_name=account_name, + live_event_name=live_event_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.operation_location.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 + ) + + 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 + if response.status_code == 200: + deserialized = self._deserialize("LiveEvent", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + operation_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/operationLocations/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_outputs_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_outputs_operations.py index fa0ce449e7d0..fdf3c9a7becd 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_outputs_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_live_outputs_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,181 +26,299 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, + resource_group_name: str, account_name: str, live_event_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_request( resource_group_name: str, account_name: str, live_event_name: str, + live_output_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + "liveOutputName": _SERIALIZER.url( + "live_output_name", + live_output_name, + "str", + max_length=256, + min_length=1, + pattern=r"^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - subscription_id: str, +def build_create_request( resource_group_name: str, account_name: str, live_event_name: str, live_output_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), - "liveOutputName": _SERIALIZER.url("live_output_name", live_output_name, 'str', max_length=256, min_length=1, pattern=r'^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + "liveOutputName": _SERIALIZER.url( + "live_output_name", + live_output_name, + "str", + max_length=256, + min_length=1, + pattern=r"^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + 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="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, - *, - json: Optional[_models.LiveOutput] = None, - content: Any = None, + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), - "liveOutputName": _SERIALIZER.url("live_output_name", live_output_name, 'str', max_length=256, min_length=1, pattern=r'^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + "liveOutputName": _SERIALIZER.url( + "live_output_name", + live_output_name, + "str", + max_length=256, + min_length=1, + pattern=r"^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_async_operation_request( + resource_group_name: str, account_name: str, operation_id: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveOutputOperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_operation_location_request( resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, + operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}/operationLocations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "liveEventName": _SERIALIZER.url("live_event_name", live_event_name, 'str', max_length=32, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), - "liveOutputName": _SERIALIZER.url("live_output_name", live_output_name, 'str', max_length=256, min_length=1, pattern=r'^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "liveEventName": _SERIALIZER.url( + "live_event_name", + live_event_name, + "str", + max_length=32, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + "liveOutputName": _SERIALIZER.url( + "live_output_name", + live_output_name, + "str", + max_length=256, + min_length=1, + pattern=r"^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$", + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class LiveOutputsOperations: """ @@ -217,51 +339,45 @@ def __init__(self, *args, **kwargs): 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, - live_event_name: str, - **kwargs: Any - ) -> Iterable[_models.LiveOutputListResult]: + self, resource_group_name: str, account_name: str, live_event_name: str, **kwargs: Any + ) -> Iterable["_models.LiveOutput"]: """List Live Outputs. Lists the live outputs of a live event. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LiveOutputListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.LiveOutputListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LiveOutput or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.LiveOutput] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutputListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveOutputListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -269,17 +385,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - live_event_name=live_event_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -295,10 +401,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -309,58 +413,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - live_output_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, **kwargs: Any ) -> _models.LiveOutput: """Get Live Output. Gets a live output. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param live_output_name: The name of the live output. + :param live_output_name: The name of the live output. Required. :type live_output_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LiveOutput, or the result of cls(response) + :return: LiveOutput or the result of cls(response) :rtype: ~azure.mgmt.media.models.LiveOutput - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutput] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LiveOutput] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, live_output_name=live_output_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -368,10 +463,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,15 +473,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore def _create_initial( self, @@ -395,33 +488,38 @@ def _create_initial( account_name: str, live_event_name: str, live_output_name: str, - parameters: _models.LiveOutput, + parameters: Union[_models.LiveOutput, IO], **kwargs: Any ) -> _models.LiveOutput: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutput] + 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.LiveOutput] - _json = self._serialize.body(parameters, 'LiveOutput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LiveOutput") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, live_output_name=live_output_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -429,31 +527,30 @@ def _create_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, @@ -461,6 +558,8 @@ def begin_create( live_event_name: str, live_output_name: str, parameters: _models.LiveOutput, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LiveOutput]: """Create Live Output. @@ -468,15 +567,62 @@ def begin_create( Creates a new live output. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param live_output_name: The name of the live output. + :param live_output_name: The name of the live output. Required. :type live_output_name: str - :param parameters: Live Output properties needed for creation. + :param parameters: Live Output properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.LiveOutput + :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 LiveOutput or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + live_output_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LiveOutput]: + """Create Live Output. + + Creates a new live output. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param live_output_name: The name of the live output. Required. + :type live_output_name: str + :param parameters: Live Output properties needed for creation. Required. + :type parameters: 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 @@ -487,20 +633,59 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either LiveOutput or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveOutput] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + live_output_name: str, + parameters: Union[_models.LiveOutput, IO], + **kwargs: Any + ) -> LROPoller[_models.LiveOutput]: + """Create Live Output. + + Creates a new live output. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param live_output_name: The name of the live output. Required. + :type live_output_name: str + :param parameters: Live Output properties needed for creation. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.media.models.LiveOutput 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 LiveOutput or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.LiveOutput] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LiveOutput] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.LiveOutput] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -510,68 +695,56 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('LiveOutput', pipeline_response) + deserialized = self._deserialize("LiveOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - live_output_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, live_output_name=live_output_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -579,30 +752,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - live_event_name: str, - live_output_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, account_name: str, live_event_name: str, live_output_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete Live Output. @@ -610,12 +777,13 @@ def begin_delete( # pylint: disable=inconsistent-return-statements writing to. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param live_event_name: The name of the live event, maximum length is 32. + :param live_event_name: The name of the live event, maximum length is 32. Required. :type live_event_name: str - :param live_output_name: The name of the live output. + :param live_output_name: The name of the live output. Required. :type live_output_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. @@ -627,19 +795,16 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -647,34 +812,168 @@ def begin_delete( # pylint: disable=inconsistent-return-statements live_event_name=live_event_name, live_output_name=live_output_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}"} # type: ignore + + @distributed_trace + def async_operation( + self, resource_group_name: str, account_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: + """Get operation status. + + Get a Live Output operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AsyncOperationResult or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AsyncOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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.AsyncOperationResult] + + request = build_async_operation_request( + resource_group_name=resource_group_name, + account_name=account_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.async_operation.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 + ) + + 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("AsyncOperationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveOutputOperations/{operationId}"} # type: ignore + + @distributed_trace + def operation_location( + self, + resource_group_name: str, + account_name: str, + live_event_name: str, + live_output_name: str, + operation_id: str, + **kwargs: Any + ) -> Optional[_models.LiveOutput]: + """Get operation status. + + Get a Live Output operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param live_event_name: The name of the live event, maximum length is 32. Required. + :type live_event_name: str + :param live_output_name: The name of the live output. Required. + :type live_output_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LiveOutput or None or the result of cls(response) + :rtype: ~azure.mgmt.media.models.LiveOutput or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[Optional[_models.LiveOutput]] + + request = build_operation_location_request( + resource_group_name=resource_group_name, + account_name=account_name, + live_event_name=live_event_name, + live_output_name=live_output_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.operation_location.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 + ) + + 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 + if response.status_code == 200: + deserialized = self._deserialize("LiveOutput", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + operation_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}/operationLocations/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_locations_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_locations_operations.py index e09438958543..a4da39c00af0 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_locations_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_locations_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,54 +23,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - location_name: str, - *, - json: Optional[_models.CheckNameAvailabilityInput] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(location_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class LocationsOperations: """ @@ -87,48 +83,99 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, location_name: str, parameters: _models.CheckNameAvailabilityInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EntityNameAvailabilityCheckOutput: """Check Name Availability. Checks whether the Media Service resource name is available. - :param location_name: Location name. + :param location_name: Location name. Required. :type location_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.CheckNameAvailabilityInput + :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: EntityNameAvailabilityCheckOutput, or the result of cls(response) + :return: EntityNameAvailabilityCheckOutput or the result of cls(response) :rtype: ~azure.mgmt.media.models.EntityNameAvailabilityCheckOutput - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def check_name_availability( + self, location_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EntityNameAvailabilityCheckOutput: + """Check Name Availability. + + Checks whether the Media Service resource name is available. + + :param location_name: Location name. Required. + :type location_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: EntityNameAvailabilityCheckOutput or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EntityNameAvailabilityCheckOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location_name: str, parameters: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + ) -> _models.EntityNameAvailabilityCheckOutput: + """Check Name Availability. + + Checks whether the Media Service resource name is available. + + :param location_name: Location name. Required. + :type location_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.CheckNameAvailabilityInput 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: EntityNameAvailabilityCheckOutput or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EntityNameAvailabilityCheckOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EntityNameAvailabilityCheckOutput] + 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.EntityNameAvailabilityCheckOutput] - _json = self._serialize.body(parameters, 'CheckNameAvailabilityInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailabilityInput") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location_name=location_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -136,10 +183,9 @@ def check_name_availability( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,12 +193,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EntityNameAvailabilityCheckOutput', pipeline_response) + deserialized = self._deserialize("EntityNameAvailabilityCheckOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_results_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_results_operations.py index 8c61b6623ff7..015b272bcf53 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_results_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_results_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,44 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - location_name: str, - operation_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(location_name: str, operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationResults/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationResults/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "locationName": _SERIALIZER.url("location_name", location_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MediaServicesOperationResultsOperations: """ @@ -81,45 +81,36 @@ def __init__(self, *args, **kwargs): 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 get( - self, - location_name: str, - operation_id: str, - **kwargs: Any - ) -> Optional[_models.MediaService]: + def get(self, location_name: str, operation_id: str, **kwargs: Any) -> Optional[_models.MediaService]: """Get operation result. Get media service operation result. - :param location_name: Location name. + :param location_name: Location name. Required. :type location_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MediaService, or the result of cls(response) + :return: MediaService or None or the result of cls(response) :rtype: ~azure.mgmt.media.models.MediaService or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MediaService]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MediaService]] - request = build_get_request( - subscription_id=self._config.subscription_id, location_name=location_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -127,10 +118,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -141,18 +131,18 @@ def get( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('MediaService', pipeline_response) + deserialized = self._deserialize("MediaService", pipeline_response) if response.status_code == 202: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationResults/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationResults/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_statuses_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_statuses_operations.py index 46e7e88ac185..782ecdfebdef 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_statuses_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_media_services_operation_statuses_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,44 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - location_name: str, - operation_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(location_name: str, operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationStatuses/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationStatuses/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "locationName": _SERIALIZER.url("location_name", location_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MediaServicesOperationStatusesOperations: """ @@ -81,45 +81,36 @@ def __init__(self, *args, **kwargs): 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 get( - self, - location_name: str, - operation_id: str, - **kwargs: Any - ) -> _models.MediaServiceOperationStatus: + def get(self, location_name: str, operation_id: str, **kwargs: Any) -> _models.MediaServiceOperationStatus: """Get operation status. Get media service operation status. - :param location_name: Location name. + :param location_name: Location name. Required. :type location_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MediaServiceOperationStatus, or the result of cls(response) + :return: MediaServiceOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.media.models.MediaServiceOperationStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaServiceOperationStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaServiceOperationStatus] - request = build_get_request( - subscription_id=self._config.subscription_id, location_name=location_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -127,10 +118,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,12 +128,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MediaServiceOperationStatus', pipeline_response) + deserialized = self._deserialize("MediaServiceOperationStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationStatuses/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/mediaServicesOperationStatuses/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_mediaservices_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_mediaservices_operations.py index fa834788434b..9256e872d57a 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_mediaservices_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_mediaservices_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,333 +26,263 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.MediaService] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_update_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.MediaServiceUpdate] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_sync_storage_keys_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.SyncStorageKeysInput] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/syncStorageKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/syncStorageKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_edge_policies_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.ListEdgePoliciesInput] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/listEdgePolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/listEdgePolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Media/mediaservices") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MediaservicesOperations: """ @@ -369,43 +303,37 @@ def __init__(self, *args, **kwargs): 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, - **kwargs: Any - ) -> Iterable[_models.MediaServiceCollection]: + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.MediaService"]: """List Media Services accounts. List Media Services accounts in the resource group. :param resource_group_name: The name of the resource group within the Azure subscription. + 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 MediaServiceCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.MediaServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MediaService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.MediaService] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaServiceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaServiceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -413,15 +341,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -437,10 +357,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -451,50 +369,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.MediaService: + def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.MediaService: """Get a Media Services account. Get the details of a Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MediaService, or the result of cls(response) + :return: MediaService or the result of cls(response) :rtype: ~azure.mgmt.media.models.MediaService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaService] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -502,10 +411,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -513,45 +421,45 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MediaService', pipeline_response) + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - account_name: str, - parameters: _models.MediaService, - **kwargs: Any + self, resource_group_name: str, account_name: str, parameters: Union[_models.MediaService, IO], **kwargs: Any ) -> _models.MediaService: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] + 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.MediaService] - _json = self._serialize.body(parameters, 'MediaService') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MediaService") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -559,45 +467,50 @@ def _create_or_update_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if response.status_code == 201: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, account_name: str, parameters: _models.MediaService, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.MediaService]: """Create or update a Media Services account. @@ -605,11 +518,85 @@ def begin_create_or_update( Creates or updates a Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.MediaService + :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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MediaService]: + """Create or update a Media Services account. + + Creates or updates a Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, account_name: str, parameters: Union[_models.MediaService, IO], **kwargs: Any + ) -> LROPoller[_models.MediaService]: + """Create or update a Media Services account. + + Creates or updates a Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.MediaService 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 @@ -621,20 +608,17 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either MediaService or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.MediaService] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.MediaService] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -642,84 +626,77 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Delete a Media Services account. Deletes a Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -727,10 +704,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -741,38 +717,42 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore def _update_initial( self, resource_group_name: str, account_name: str, - parameters: _models.MediaServiceUpdate, + parameters: Union[_models.MediaServiceUpdate, IO], **kwargs: Any ) -> _models.MediaService: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] + 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.MediaService] - _json = self._serialize.body(parameters, 'MediaServiceUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MediaServiceUpdate") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -780,37 +760,40 @@ def _update_initial( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize('MediaService', pipeline_response) + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, account_name: str, parameters: _models.MediaServiceUpdate, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.MediaService]: """Update a Media Services account. @@ -818,11 +801,15 @@ def begin_update( Updates an existing Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.MediaServiceUpdate + :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 @@ -834,20 +821,91 @@ def begin_update( :return: An instance of LROPoller that returns either MediaService or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.MediaService] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MediaService]: + """Update a Media Services account. + + Updates an existing Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.MediaServiceUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.MediaService]: + """Update a Media Services account. + + Updates an existing Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.MediaServiceUpdate 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 MediaService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.MediaService] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaService] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.MediaService] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -855,52 +913,52 @@ def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('MediaService', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MediaService", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}"} # type: ignore - @distributed_trace + @overload def sync_storage_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, parameters: _models.SyncStorageKeysInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Synchronizes Storage Account Keys. @@ -909,38 +967,107 @@ def sync_storage_keys( # pylint: disable=inconsistent-return-statements account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.SyncStorageKeysInput + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def sync_storage_keys( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Synchronizes Storage Account Keys. + + Synchronizes storage account keys for a storage account associated with the Media Service + account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def sync_storage_keys( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.SyncStorageKeysInput, IO], + **kwargs: Any + ) -> None: + """Synchronizes Storage Account Keys. + + Synchronizes storage account keys for a storage account associated with the Media Service + account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.SyncStorageKeysInput 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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[None] - _json = self._serialize.body(parameters, 'SyncStorageKeysInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncStorageKeysInput") request = build_sync_storage_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.sync_storage_keys.metadata['url'], + content=_content, + template_url=self.sync_storage_keys.metadata["url"], headers=_headers, params=_params, ) @@ -948,10 +1075,9 @@ def sync_storage_keys( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,15 +1088,16 @@ def sync_storage_keys( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - sync_storage_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/syncStorageKeys"} # type: ignore - + sync_storage_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/syncStorageKeys"} # type: ignore - @distributed_trace + @overload def list_edge_policies( self, resource_group_name: str, account_name: str, parameters: _models.ListEdgePoliciesInput, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EdgePolicies: """List the media edge policies associated with the Media Services account. @@ -978,38 +1105,105 @@ def list_edge_policies( List all the media edge policies associated with the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.ListEdgePoliciesInput + :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: EdgePolicies or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EdgePolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_edge_policies( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EdgePolicies: + """List the media edge policies associated with the Media Services account. + + List all the media edge policies associated with the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: EdgePolicies, or the result of cls(response) + :return: EdgePolicies or the result of cls(response) :rtype: ~azure.mgmt.media.models.EdgePolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def list_edge_policies( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ListEdgePoliciesInput, IO], + **kwargs: Any + ) -> _models.EdgePolicies: + """List the media edge policies associated with the Media Services account. + + List all the media edge policies associated with the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.ListEdgePoliciesInput 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: EdgePolicies or the result of cls(response) + :rtype: ~azure.mgmt.media.models.EdgePolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EdgePolicies] + 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.EdgePolicies] - _json = self._serialize.body(parameters, 'ListEdgePoliciesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ListEdgePoliciesInput") request = build_list_edge_policies_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_edge_policies.metadata['url'], + content=_content, + template_url=self.list_edge_policies.metadata["url"], headers=_headers, params=_params, ) @@ -1017,10 +1211,9 @@ def list_edge_policies( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1028,48 +1221,42 @@ def list_edge_policies( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EdgePolicies', pipeline_response) + deserialized = self._deserialize("EdgePolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_edge_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/listEdgePolicies"} # type: ignore - + list_edge_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/listEdgePolicies"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.MediaServiceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.MediaService"]: """List Media Services accounts. List Media Services accounts in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MediaServiceCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.MediaServiceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MediaService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.MediaService] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MediaServiceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MediaServiceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -1077,14 +1264,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1100,10 +1280,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1114,8 +1292,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Media/mediaservices"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Media/mediaservices"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_results_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_results_operations.py index 5275cd9105ba..615960a79f3d 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_results_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_results_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,54 +23,55 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, account_name: str, asset_name: str, track_name: str, operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationResults/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationResults/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class OperationResultsOperations: """ @@ -87,7 +92,6 @@ def __init__(self, *args, **kwargs): 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 get( self, @@ -103,41 +107,39 @@ def get( Get asset track operation result. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetTrack, or the result of cls(response) + :return: AssetTrack or None or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetTrack or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AssetTrack]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AssetTrack]] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -145,10 +147,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -159,18 +160,18 @@ def get( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('AssetTrack', pipeline_response) + deserialized = self._deserialize("AssetTrack", pipeline_response) if response.status_code == 202: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationResults/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_statuses_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_statuses_operations.py index c0e977651aba..2e8c2d5ccb8e 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_statuses_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operation_statuses_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,54 +23,55 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, account_name: str, asset_name: str, track_name: str, operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class OperationStatusesOperations: """ @@ -87,7 +92,6 @@ def __init__(self, *args, **kwargs): 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 get( self, @@ -103,41 +107,39 @@ def get( Get asset track operation status. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetTrackOperationStatus, or the result of cls(response) + :return: AssetTrackOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetTrackOperationStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrackOperationStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetTrackOperationStatus] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, operation_id=operation_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -145,10 +147,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,12 +157,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetTrackOperationStatus', pipeline_response) + deserialized = self._deserialize("AssetTrackOperationStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operations.py index 18b410a8fc73..6419019ec068 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,38 +23,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Media/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -71,36 +71,29 @@ def __init__(self, *args, **kwargs): 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, - **kwargs: Any - ) -> _models.OperationCollection: + def list(self, **kwargs: Any) -> _models.OperationCollection: """List Operations. Lists all the Media Services operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationCollection, or the result of cls(response) + :return: OperationCollection or the result of cls(response) :rtype: ~azure.mgmt.media.models.OperationCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationCollection] - request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,10 +101,9 @@ def list( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,12 +111,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationCollection', pipeline_response) + deserialized = self._deserialize("OperationCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Media/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Media/operations"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_patch.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_patch.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_endpoint_connections_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_endpoint_connections_operations.py index 14a4b632b621..9bf73a19ba85 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_endpoint_connections_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,173 +23,143 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + resource_group_name: str, account_name: str, 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + resource_group_name: str, account_name: str, 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -206,45 +180,39 @@ def __init__(self, *args, **kwargs): 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 + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnectionListResult: """List private endpoint connections. List all private endpoint connections. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionListResult, or the result of cls(response) + :return: PrivateEndpointConnectionListResult or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateEndpointConnectionListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + 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] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -252,10 +220,9 @@ def list( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,58 +230,51 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get the details of a private endpoint connection. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + 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] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -322,10 +282,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,23 +292,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update a private endpoint connection. @@ -357,41 +317,114 @@ def create_or_update( Update an existing private endpoint connection. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update a private endpoint connection. + + Update an existing private endpoint connection. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param name: Required. + :type name: str + :param parameters: The request parameters. Required. + :type parameters: 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update a private endpoint connection. + + Update an existing private endpoint connection. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param name: Required. + :type name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.PrivateEndpointConnection 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.media.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + 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] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -399,10 +432,9 @@ def create_or_update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,58 +442,51 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, name: str, **kwargs: Any ) -> None: """Delete a private endpoint connection. Deletes a private endpoint connection. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -469,10 +494,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -483,5 +507,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_link_resources_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_link_resources_operations.py index a6f816b09312..c982edd23be9 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_link_resources_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_private_link_resources_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,87 +23,76 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any + resource_group_name: str, account_name: str, 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -120,45 +113,37 @@ def __init__(self, *args, **kwargs): 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 - ) -> _models.PrivateLinkResourceListResult: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.PrivateLinkResourceListResult: """Get list of group IDs. List supported group IDs. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + 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] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -166,10 +151,9 @@ def list( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,58 +161,49 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - name: str, - **kwargs: Any - ) -> _models.PrivateLinkResource: + def get(self, resource_group_name: str, account_name: str, name: str, **kwargs: Any) -> _models.PrivateLinkResource: """Get group ID. Get details of a group ID. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param name: + :param name: Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.media.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -236,10 +211,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,12 +221,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_endpoints_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_endpoints_operations.py index 215b4d7dc196..59758ecdcda6 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_endpoints_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_endpoints_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,387 +26,450 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, account_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, account_name: str, streaming_endpoint_name: str, + subscription_id: str, *, - json: Optional[_models.StreamingEndpoint] = None, - content: Any = None, auto_start: Optional[bool] = None, **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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if auto_start is not None: - _params['autoStart'] = _SERIALIZER.query("auto_start", auto_start, 'bool') + _params["autoStart"] = _SERIALIZER.query("auto_start", auto_start, "bool") # 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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - *, - json: Optional[_models.StreamingEndpoint] = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_skus_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any +def build_start_request( + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any +def build_stop_request( + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_scale_request_initial( - subscription_id: str, +def build_scale_request( + resource_group_name: str, account_name: str, streaming_endpoint_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_async_operation_request( + resource_group_name: str, account_name: str, operation_id: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpointOperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_operation_location_request( resource_group_name: str, account_name: str, streaming_endpoint_name: str, - *, - json: Optional[_models.StreamingEntityScaleUnit] = None, - content: Any = None, + operation_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/operationLocations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingEndpointName": _SERIALIZER.url("streaming_endpoint_name", streaming_endpoint_name, 'str', max_length=24, min_length=1, pattern=r'^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingEndpointName": _SERIALIZER.url( + "streaming_endpoint_name", + streaming_endpoint_name, + "str", + max_length=24, + min_length=1, + pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class StreamingEndpointsOperations: """ @@ -423,47 +490,40 @@ def __init__(self, *args, **kwargs): 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.StreamingEndpointListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.StreamingEndpoint"]: """List StreamingEndpoints. Lists the streaming endpoints in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. 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 StreamingEndpointListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.StreamingEndpointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StreamingEndpoint or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.StreamingEndpoint] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpointListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingEndpointListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -471,16 +531,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -496,10 +547,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -510,54 +559,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> _models.StreamingEndpoint: """Get StreamingEndpoint. Gets a streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingEndpoint, or the result of cls(response) + :return: StreamingEndpoint or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingEndpoint - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingEndpoint] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -565,10 +607,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -576,49 +617,53 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, - parameters: _models.StreamingEndpoint, + parameters: Union[_models.StreamingEndpoint, IO], auto_start: Optional[bool] = None, **kwargs: Any ) -> _models.StreamingEndpoint: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] + 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.StreamingEndpoint] - _json = self._serialize.body(parameters, 'StreamingEndpoint') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingEndpoint") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, + auto_start=auto_start, api_version=api_version, content_type=content_type, json=_json, - auto_start=auto_start, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -626,31 +671,30 @@ def _create_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, @@ -658,6 +702,8 @@ def begin_create( streaming_endpoint_name: str, parameters: _models.StreamingEndpoint, auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StreamingEndpoint]: """Create StreamingEndpoint. @@ -665,16 +711,21 @@ def begin_create( Creates a streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str - :param parameters: Streaming endpoint properties needed for creation. + :param parameters: Streaming endpoint properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.StreamingEndpoint :param auto_start: The flag indicates if the resource should be automatically started on creation. Default value is None. :type auto_start: bool + :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 @@ -686,20 +737,108 @@ def begin_create( :return: An instance of LROPoller that returns either StreamingEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.StreamingEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: IO, + auto_start: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StreamingEndpoint]: + """Create StreamingEndpoint. + + Creates a streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Required. + :type parameters: IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: Union[_models.StreamingEndpoint, IO], + auto_start: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[_models.StreamingEndpoint]: + """Create StreamingEndpoint. + + Creates a streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingEndpoint or IO + :param auto_start: The flag indicates if the resource should be automatically started on + creation. Default value is None. + :type auto_start: bool + :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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.StreamingEndpoint] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -709,71 +848,72 @@ def begin_create( auto_start=auto_start, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore def _update_initial( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, - parameters: _models.StreamingEndpoint, + parameters: Union[_models.StreamingEndpoint, IO], **kwargs: Any ) -> _models.StreamingEndpoint: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] + 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.StreamingEndpoint] - _json = self._serialize.body(parameters, 'StreamingEndpoint') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingEndpoint") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -781,37 +921,38 @@ def _update_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, parameters: _models.StreamingEndpoint, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StreamingEndpoint]: """Update StreamingEndpoint. @@ -819,13 +960,18 @@ def begin_update( Updates a existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str - :param parameters: Streaming endpoint properties needed for creation. + :param parameters: Streaming endpoint properties needed for creation. Required. :type parameters: ~azure.mgmt.media.models.StreamingEndpoint + :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 @@ -837,20 +983,100 @@ def begin_update( :return: An instance of LROPoller that returns either StreamingEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.StreamingEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StreamingEndpoint]: + """Update StreamingEndpoint. + + Updates a existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Required. + :type parameters: 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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: Union[_models.StreamingEndpoint, IO], + **kwargs: Any + ) -> LROPoller[_models.StreamingEndpoint]: + """Update StreamingEndpoint. + + Updates a existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint properties needed for creation. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingEndpoint 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 StreamingEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.StreamingEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpoint] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.StreamingEndpoint] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -859,66 +1085,55 @@ def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StreamingEndpoint', pipeline_response) + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -926,39 +1141,36 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete StreamingEndpoint. Deletes a streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_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. @@ -970,99 +1182,87 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}"} # type: ignore @distributed_trace def skus( - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> _models.StreamingEndpointSkuInfoListResult: """List StreamingEndpoint skus. List streaming endpoint supported skus. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingEndpointSkuInfoListResult, or the result of cls(response) + :return: StreamingEndpointSkuInfoListResult or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingEndpointSkuInfoListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingEndpointSkuInfoListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingEndpointSkuInfoListResult] - request = build_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.skus.metadata['url'], + template_url=self.skus.metadata["url"], headers=_headers, params=_params, ) @@ -1070,10 +1270,9 @@ def skus( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1081,42 +1280,34 @@ def skus( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingEndpointSkuInfoListResult', pipeline_response) + deserialized = self._deserialize("StreamingEndpointSkuInfoListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - skus.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus"} # type: ignore - + skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1124,39 +1315,36 @@ def _start_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> LROPoller[None]: """Start StreamingEndpoint. Starts an existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_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. @@ -1168,83 +1356,69 @@ def begin_start( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + request = build_stop_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1252,39 +1426,36 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_endpoint_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop StreamingEndpoint. Stops an existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_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. @@ -1296,88 +1467,86 @@ def begin_stop( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop"} # type: ignore def _scale_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, - parameters: _models.StreamingEntityScaleUnit, + parameters: Union[_models.StreamingEntityScaleUnit, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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[None] - _json = self._serialize.body(parameters, 'StreamingEntityScaleUnit') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingEntityScaleUnit") - request = build_scale_request_initial( - subscription_id=self._config.subscription_id, + request = build_scale_request( resource_group_name=resource_group_name, account_name=account_name, streaming_endpoint_name=streaming_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._scale_initial.metadata['url'], + content=_content, + template_url=self._scale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1385,29 +1554,30 @@ def _scale_initial( # pylint: disable=inconsistent-return-statements 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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, {}) - _scale_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore - + _scale_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore - @distributed_trace - def begin_scale( # pylint: disable=inconsistent-return-statements + @overload + def begin_scale( self, resource_group_name: str, account_name: str, streaming_endpoint_name: str, parameters: _models.StreamingEntityScaleUnit, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Scale StreamingEndpoint. @@ -1415,13 +1585,59 @@ def begin_scale( # pylint: disable=inconsistent-return-statements Scales an existing streaming endpoint. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. :type streaming_endpoint_name: str - :param parameters: Streaming endpoint scale parameters. + :param parameters: Streaming endpoint scale parameters. Required. :type parameters: ~azure.mgmt.media.models.StreamingEntityScaleUnit + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_scale( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Scale StreamingEndpoint. + + Scales an existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint scale parameters. Required. + :type parameters: 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 @@ -1432,20 +1648,57 @@ def begin_scale( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_scale( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + parameters: Union[_models.StreamingEntityScaleUnit, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Scale StreamingEndpoint. + + Scales an existing streaming endpoint. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param parameters: Streaming endpoint scale parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.media.models.StreamingEntityScaleUnit 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._scale_initial( # type: ignore resource_group_name=resource_group_name, @@ -1454,34 +1707,165 @@ def begin_scale( # pylint: disable=inconsistent-return-statements parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scale.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore + begin_scale.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale"} # type: ignore + + @distributed_trace + def async_operation( + self, resource_group_name: str, account_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: + """Get operation status. + + Get a streaming endpoint operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AsyncOperationResult or the result of cls(response) + :rtype: ~azure.mgmt.media.models.AsyncOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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.AsyncOperationResult] + + request = build_async_operation_request( + resource_group_name=resource_group_name, + account_name=account_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.async_operation.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 + ) + + 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("AsyncOperationResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpointOperations/{operationId}"} # type: ignore + + @distributed_trace + def operation_location( + self, + resource_group_name: str, + account_name: str, + streaming_endpoint_name: str, + operation_id: str, + **kwargs: Any + ) -> Optional[_models.StreamingEndpoint]: + """Get operation status. + + Get a streaming endpoint operation status. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_endpoint_name: The name of the streaming endpoint, maximum length is 24. + Required. + :type streaming_endpoint_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StreamingEndpoint or None or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingEndpoint or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[Optional[_models.StreamingEndpoint]] + + request = build_operation_location_request( + resource_group_name=resource_group_name, + account_name=account_name, + streaming_endpoint_name=streaming_endpoint_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.operation_location.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 + ) + + 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 + if response.status_code == 200: + deserialized = self._deserialize("StreamingEndpoint", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + operation_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/operationLocations/{operationId}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_locators_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_locators_operations.py index b0d12835db01..c18744d190d8 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_locators_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_locators_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,17 +24,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, account_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, @@ -40,241 +47,199 @@ def build_list_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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_locator_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - *, - json: Optional[_models.StreamingLocator] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_locator_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_locator_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_content_keys_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_locator_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_paths_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_locator_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingLocatorName": _SERIALIZER.url("streaming_locator_name", streaming_locator_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class StreamingLocatorsOperations: """ @@ -295,7 +260,6 @@ def __init__(self, *args, **kwargs): 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, @@ -305,14 +269,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.StreamingLocatorCollection]: + ) -> Iterable["_models.StreamingLocator"]: """List Streaming Locators. Lists the Streaming Locators in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -324,33 +289,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StreamingLocatorCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.StreamingLocatorCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StreamingLocator or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.StreamingLocator] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingLocatorCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingLocatorCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -358,19 +321,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -386,10 +337,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -400,54 +349,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> _models.StreamingLocator: """Get a Streaming Locator. Get the details of a Streaming Locator in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingLocator, or the result of cls(response) + :return: StreamingLocator or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingLocator - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingLocator] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingLocator] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -455,10 +396,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,23 +406,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingLocator', pipeline_response) + deserialized = self._deserialize("StreamingLocator", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, streaming_locator_name: str, parameters: _models.StreamingLocator, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StreamingLocator: """Create a Streaming Locator. @@ -490,41 +431,114 @@ def create( Create a Streaming Locator in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.StreamingLocator + :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: StreamingLocator, or the result of cls(response) + :return: StreamingLocator or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingLocator - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + streaming_locator_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StreamingLocator: + """Create a Streaming Locator. + + Create a Streaming Locator in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_locator_name: The Streaming Locator name. Required. + :type streaming_locator_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: StreamingLocator or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingLocator + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + streaming_locator_name: str, + parameters: Union[_models.StreamingLocator, IO], + **kwargs: Any + ) -> _models.StreamingLocator: + """Create a Streaming Locator. + + Create a Streaming Locator in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_locator_name: The Streaming Locator name. Required. + :type streaming_locator_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingLocator 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: StreamingLocator or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingLocator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingLocator] + 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.StreamingLocator] - _json = self._serialize.body(parameters, 'StreamingLocator') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingLocator") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -532,10 +546,9 @@ def create( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -543,58 +556,51 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingLocator', pipeline_response) + deserialized = self._deserialize("StreamingLocator", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> None: """Delete a Streaming Locator. Deletes a Streaming Locator in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -602,10 +608,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -616,51 +621,44 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}"} # type: ignore @distributed_trace def list_content_keys( - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> _models.ListContentKeysResponse: """List Content Keys. List Content Keys used by this Streaming Locator. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContentKeysResponse, or the result of cls(response) + :return: ListContentKeysResponse or the result of cls(response) :rtype: ~azure.mgmt.media.models.ListContentKeysResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContentKeysResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContentKeysResponse] - request = build_list_content_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_content_keys.metadata['url'], + template_url=self.list_content_keys.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +666,9 @@ def list_content_keys( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,58 +676,51 @@ def list_content_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContentKeysResponse', pipeline_response) + deserialized = self._deserialize("ListContentKeysResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_content_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys"} # type: ignore - + list_content_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys"} # type: ignore @distributed_trace def list_paths( - self, - resource_group_name: str, - account_name: str, - streaming_locator_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_locator_name: str, **kwargs: Any ) -> _models.ListPathsResponse: """List Paths. List Paths supported by this Streaming Locator. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_locator_name: The Streaming Locator name. + :param streaming_locator_name: The Streaming Locator name. Required. :type streaming_locator_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListPathsResponse, or the result of cls(response) + :return: ListPathsResponse or the result of cls(response) :rtype: ~azure.mgmt.media.models.ListPathsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPathsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListPathsResponse] - request = build_list_paths_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_locator_name=streaming_locator_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_paths.metadata['url'], + template_url=self.list_paths.metadata["url"], headers=_headers, params=_params, ) @@ -738,10 +728,9 @@ def list_paths( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -749,12 +738,11 @@ def list_paths( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListPathsResponse', pipeline_response) + deserialized = self._deserialize("ListPathsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_paths.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths"} # type: ignore - + list_paths.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_policies_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_policies_operations.py index 663327ccd16b..79bfe587d742 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_policies_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_streaming_policies_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,17 +24,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, account_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, @@ -40,163 +47,135 @@ def build_list_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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingPolicyName": _SERIALIZER.url("streaming_policy_name", streaming_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingPolicyName": _SERIALIZER.url("streaming_policy_name", streaming_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - *, - json: Optional[_models.StreamingPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingPolicyName": _SERIALIZER.url("streaming_policy_name", streaming_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingPolicyName": _SERIALIZER.url("streaming_policy_name", streaming_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, streaming_policy_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "streamingPolicyName": _SERIALIZER.url("streaming_policy_name", streaming_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "streamingPolicyName": _SERIALIZER.url("streaming_policy_name", streaming_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class StreamingPoliciesOperations: """ @@ -217,7 +196,6 @@ def __init__(self, *args, **kwargs): 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, @@ -227,14 +205,15 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.StreamingPolicyCollection]: + ) -> Iterable["_models.StreamingPolicy"]: """List Streaming Policies. Lists the Streaming Policies in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -246,33 +225,31 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StreamingPolicyCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.StreamingPolicyCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StreamingPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.StreamingPolicy] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingPolicyCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingPolicyCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -280,19 +257,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - top=top, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -308,10 +273,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -322,54 +285,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_policy_name: str, **kwargs: Any ) -> _models.StreamingPolicy: """Get a Streaming Policy. Get the details of a Streaming Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_policy_name: The Streaming Policy name. + :param streaming_policy_name: The Streaming Policy name. Required. :type streaming_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StreamingPolicy, or the result of cls(response) + :return: StreamingPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.StreamingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_policy_name=streaming_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -377,10 +332,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,23 +342,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingPolicy', pipeline_response) + deserialized = self._deserialize("StreamingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, streaming_policy_name: str, parameters: _models.StreamingPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StreamingPolicy: """Create a Streaming Policy. @@ -412,41 +367,114 @@ def create( Create a Streaming Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_policy_name: The Streaming Policy name. + :param streaming_policy_name: The Streaming Policy name. Required. :type streaming_policy_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.StreamingPolicy + :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: StreamingPolicy, or the result of cls(response) + :return: StreamingPolicy or the result of cls(response) :rtype: ~azure.mgmt.media.models.StreamingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + streaming_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StreamingPolicy: + """Create a Streaming Policy. + + Create a Streaming Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_policy_name: The Streaming Policy name. Required. + :type streaming_policy_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: StreamingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + streaming_policy_name: str, + parameters: Union[_models.StreamingPolicy, IO], + **kwargs: Any + ) -> _models.StreamingPolicy: + """Create a Streaming Policy. + + Create a Streaming Policy in the Media Services account. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param streaming_policy_name: The Streaming Policy name. Required. + :type streaming_policy_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.StreamingPolicy 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: StreamingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.media.models.StreamingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StreamingPolicy] + 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.StreamingPolicy] - _json = self._serialize.body(parameters, 'StreamingPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StreamingPolicy") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_policy_name=streaming_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -454,10 +482,9 @@ def create( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -465,58 +492,51 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StreamingPolicy', pipeline_response) + deserialized = self._deserialize("StreamingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - streaming_policy_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, streaming_policy_name: str, **kwargs: Any ) -> None: """Delete a Streaming Policy. Deletes a Streaming Policy in the Media Services account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param streaming_policy_name: The Streaming Policy name. + :param streaming_policy_name: The Streaming Policy name. Required. :type streaming_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, streaming_policy_name=streaming_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -524,10 +544,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,5 +557,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_tracks_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_tracks_operations.py index 6ca9feb848ad..656156ccad07 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_tracks_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_tracks_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,271 +26,218 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, asset_name: str, track_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - *, - json: Optional[_models.AssetTrack] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, account_name: str, asset_name: str, track_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + _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_request( + resource_group_name: str, account_name: str, asset_name: str, track_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_update_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - *, - json: Optional[_models.AssetTrack] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, asset_name: str, track_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) - - -def build_update_track_data_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + _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_update_track_data_request( + resource_group_name: str, account_name: str, asset_name: str, track_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "assetName": _SERIALIZER.url("asset_name", asset_name, 'str'), - "trackName": _SERIALIZER.url("track_name", track_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + "trackName": _SERIALIZER.url("track_name", track_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TracksOperations: """ @@ -307,51 +258,45 @@ def __init__(self, *args, **kwargs): 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, - asset_name: str, - **kwargs: Any - ) -> Iterable[_models.AssetTrackCollection]: + self, resource_group_name: str, account_name: str, asset_name: str, **kwargs: Any + ) -> Iterable["_models.AssetTrack"]: """List Tracks in the Asset. Lists the Tracks in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AssetTrackCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AssetTrackCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AssetTrack or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.AssetTrack] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrackCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetTrackCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -359,17 +304,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - asset_name=asset_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -385,10 +320,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -399,58 +332,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> _models.AssetTrack: """Get a Track. Get the details of a Track in the Asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AssetTrack, or the result of cls(response) + :return: AssetTrack or the result of cls(response) :rtype: ~azure.mgmt.media.models.AssetTrack - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AssetTrack] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -458,10 +382,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -469,15 +392,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AssetTrack', pipeline_response) + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore def _create_or_update_initial( self, @@ -485,33 +407,38 @@ def _create_or_update_initial( account_name: str, asset_name: str, track_name: str, - parameters: _models.AssetTrack, + parameters: Union[_models.AssetTrack, IO], **kwargs: Any ) -> _models.AssetTrack: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] + 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.AssetTrack] - _json = self._serialize.body(parameters, 'AssetTrack') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetTrack") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -519,40 +446,43 @@ def _create_or_update_initial( 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 + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if response.status_code == 201: - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -560,6 +490,8 @@ def begin_create_or_update( asset_name: str, track_name: str, parameters: _models.AssetTrack, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AssetTrack]: """Create or update a Track. @@ -567,15 +499,62 @@ def begin_create_or_update( Create or update a Track in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetTrack + :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 AssetTrack or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetTrack]: + """Create or update a Track. + + Create or update a Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 @@ -586,20 +565,58 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either AssetTrack or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.AssetTrack] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: Union[_models.AssetTrack, IO], + **kwargs: Any + ) -> LROPoller[_models.AssetTrack]: + """Create or update a Track. + + Create or update a Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetTrack 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 AssetTrack or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.AssetTrack] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -609,74 +626,64 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -684,49 +691,45 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, None, response_headers) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a Track. Deletes a Track in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_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. @@ -738,19 +741,16 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -758,37 +758,33 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asset_name=asset_name, track_name=track_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore def _update_initial( self, @@ -796,33 +792,38 @@ def _update_initial( account_name: str, asset_name: str, track_name: str, - parameters: _models.AssetTrack, + parameters: Union[_models.AssetTrack, IO], **kwargs: Any ) -> _models.AssetTrack: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] + 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.AssetTrack] - _json = self._serialize.body(parameters, 'AssetTrack') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AssetTrack") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -830,32 +831,33 @@ def _update_initial( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize('AssetTrack', pipeline_response) + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, @@ -863,6 +865,8 @@ def begin_update( asset_name: str, track_name: str, parameters: _models.AssetTrack, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AssetTrack]: """Update an Track. @@ -870,15 +874,62 @@ def begin_update( Updates an existing Track in the asset. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.AssetTrack + :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 AssetTrack or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetTrack]: + """Update an Track. + + Updates an existing Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Required. + :type parameters: 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 @@ -889,20 +940,58 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either AssetTrack or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.AssetTrack] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + asset_name: str, + track_name: str, + parameters: Union[_models.AssetTrack, IO], + **kwargs: Any + ) -> LROPoller[_models.AssetTrack]: + """Update an Track. + + Updates an existing Track in the asset. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param asset_name: The Asset name. Required. + :type asset_name: str + :param track_name: The Asset Track name. Required. + :type track_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.AssetTrack 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 AssetTrack or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.media.models.AssetTrack] + :raises ~azure.core.exceptions.HttpResponseError: """ _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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AssetTrack] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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.AssetTrack] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -912,74 +1001,64 @@ def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('AssetTrack', pipeline_response) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("AssetTrack", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}"} # type: ignore def _update_track_data_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_update_track_data_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_track_data_request( resource_group_name=resource_group_name, account_name=account_name, asset_name=asset_name, track_name=track_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._update_track_data_initial.metadata['url'], + template_url=self._update_track_data_initial.metadata["url"], headers=_headers, params=_params, ) @@ -987,36 +1066,31 @@ def _update_track_data_initial( # pylint: disable=inconsistent-return-statement 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: return cls(pipeline_response, None, response_headers) - _update_track_data_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore - + _update_track_data_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore @distributed_trace - def begin_update_track_data( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - asset_name: str, - track_name: str, - **kwargs: Any + def begin_update_track_data( + self, resource_group_name: str, account_name: str, asset_name: str, track_name: str, **kwargs: Any ) -> LROPoller[None]: """Update the track data. @@ -1027,12 +1101,13 @@ def begin_update_track_data( # pylint: disable=inconsistent-return-statements to be purged if applicable. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param asset_name: The Asset name. + :param asset_name: The Asset name. Required. :type asset_name: str - :param track_name: The Asset Track name. + :param track_name: The Asset Track name. Required. :type track_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. @@ -1044,19 +1119,16 @@ def begin_update_track_data( # pylint: disable=inconsistent-return-statements 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 + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_track_data_initial( # type: ignore resource_group_name=resource_group_name, @@ -1064,34 +1136,30 @@ def begin_update_track_data( # pylint: disable=inconsistent-return-statements asset_name=asset_name, track_name=track_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + 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 + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_track_data.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore + begin_update_track_data.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData"} # type: ignore diff --git a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_transforms_operations.py b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_transforms_operations.py index 4f4fd04c10a5..ad9be5949721 100644 --- a/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_transforms_operations.py +++ b/sdk/media/azure-mgmt-media/azure/mgmt/media/operations/_transforms_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,17 +24,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, account_name: str, + subscription_id: str, *, filter: Optional[str] = None, orderby: Optional[str] = None, @@ -39,208 +46,168 @@ def build_list_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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, transform_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - *, - json: Optional[_models.Transform] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, transform_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, transform_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - transform_name: str, - *, - json: Optional[_models.Transform] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, transform_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str'), - "transformName": _SERIALIZER.url("transform_name", transform_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "transformName": _SERIALIZER.url("transform_name", transform_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - json=json, - content=content, - **kwargs - ) + _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) + class TransformsOperations: """ @@ -261,7 +228,6 @@ def __init__(self, *args, **kwargs): 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, @@ -270,14 +236,15 @@ def list( filter: Optional[str] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.TransformCollection]: + ) -> Iterable["_models.Transform"]: """List Transforms. Lists the Transforms in the account. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str :param filter: Restricts the set of items returned. Default value is None. :type filter: str @@ -285,31 +252,30 @@ def list( value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransformCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.TransformCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Transform or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.media.models.Transform] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TransformCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransformCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, orderby=orderby, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -317,18 +283,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - orderby=orderby, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -344,10 +299,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -358,54 +311,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - transform_name: str, - **kwargs: Any - ) -> _models.Transform: + def get(self, resource_group_name: str, account_name: str, transform_name: str, **kwargs: Any) -> _models.Transform: """Get Transform. Gets a Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Transform, or the result of cls(response) + :return: Transform or the result of cls(response) :rtype: ~azure.mgmt.media.models.Transform - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Transform] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Transform] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +356,9 @@ def get( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,23 +366,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, transform_name: str, parameters: _models.Transform, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Transform: """Create or Update Transform. @@ -448,41 +391,114 @@ def create_or_update( Creates or updates a new Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Transform + :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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Transform: + """Create or Update Transform. + + Creates or updates a new Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Transform, or the result of cls(response) + :return: Transform or the result of cls(response) :rtype: ~azure.mgmt.media.models.Transform - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: Union[_models.Transform, IO], + **kwargs: Any + ) -> _models.Transform: + """Create or Update Transform. + + Creates or updates a new Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Transform 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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Transform] + 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.Transform] - _json = self._serialize.body(parameters, 'Transform') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Transform") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +506,9 @@ def create_or_update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -502,61 +517,54 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - transform_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, transform_name: str, **kwargs: Any ) -> None: """Delete Transform. Deletes a Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -564,10 +572,9 @@ def delete( # pylint: disable=inconsistent-return-statements 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -578,16 +585,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, transform_name: str, parameters: _models.Transform, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Transform: """Update Transform. @@ -595,41 +603,114 @@ def update( Updates a Transform. :param resource_group_name: The name of the resource group within the Azure subscription. + Required. :type resource_group_name: str - :param account_name: The Media Services account name. + :param account_name: The Media Services account name. Required. :type account_name: str - :param transform_name: The Transform name. + :param transform_name: The Transform name. Required. :type transform_name: str - :param parameters: The request parameters. + :param parameters: The request parameters. Required. :type parameters: ~azure.mgmt.media.models.Transform + :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: Transform, or the result of cls(response) + :return: Transform or the result of cls(response) :rtype: ~azure.mgmt.media.models.Transform - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Transform: + """Update Transform. + + Updates a Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Required. + :type parameters: 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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + transform_name: str, + parameters: Union[_models.Transform, IO], + **kwargs: Any + ) -> _models.Transform: + """Update Transform. + + Updates a Transform. + + :param resource_group_name: The name of the resource group within the Azure subscription. + Required. + :type resource_group_name: str + :param account_name: The Media Services account name. Required. + :type account_name: str + :param transform_name: The Transform name. Required. + :type transform_name: str + :param parameters: The request parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.media.models.Transform 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: Transform or the result of cls(response) + :rtype: ~azure.mgmt.media.models.Transform + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + 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', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Transform] + 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.Transform] - _json = self._serialize.body(parameters, 'Transform') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Transform") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, transform_name=transform_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -637,10 +718,9 @@ def update( 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 + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -648,12 +728,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Transform', pipeline_response) + deserialized = self._deserialize("Transform", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}"} # type: ignore